Re: [PATCH 1/2] net: ethernet: renesas: ravb: use phydev from struct net_device

2016-08-20 Thread David Miller
From: Philippe Reynes 
Date: Sat, 20 Aug 2016 00:52:18 +0200

> The private structure contain a pointer to phydev, but the structure
> net_device already contain such pointer. So we can remove the pointer
> phy_dev in the private structure, and update the driver to use the
> one contained in struct net_device.
> 
> Signed-off-by: Philippe Reynes 

Applied.


Re: [PATCH 2/2] net: ethernet: renesas: ravb: use new api ethtool_{get|set}_link_ksettings

2016-08-20 Thread David Miller
From: Philippe Reynes 
Date: Sat, 20 Aug 2016 00:52:19 +0200

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
> 
> Signed-off-by: Philippe Reynes 

Applied.


Re: [PATCH] net: xilinx: emaclite: Fallback to random MAC address.

2016-08-20 Thread David Miller
From: Daniel Romell 
Date: Fri, 19 Aug 2016 14:12:01 +0200

> If the address configured in the device tree is invalid, the
> driver will fallback to using a random address from the locally
> administered range.
> 
> Signed-off-by: Daniel Romell 

Applied.


Re: [net-next 0/6][pull request] 10GbE Intel Wired LAN Driver Updates 2016-08-20

2016-08-20 Thread David Miller
From: Jeff Kirsher 
Date: Sat, 20 Aug 2016 20:22:16 -0700

> This series contains updates to ixgbe and ixgbevf.

Pulled, thanks Jeff.


[net-next 1/6] ixgbe: report correct media type for KR, KX and KX4 interfaces

2016-08-20 Thread Jeff Kirsher
From: Veola Nazareth 

ethtool reports backplane type interfaces as 1000/1baseT link modes.
This has been corrected to report the media as KR, KX or KX4 based on the
backplane interface present.

Signed-off-by: Veola Nazareth 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 0d7209e..9547191 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -193,7 +193,9 @@ static int ixgbe_get_settings(struct net_device *netdev,
if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
ecmd->supported |= ixgbe_get_supported_10gtypes(hw);
if (supported_link & IXGBE_LINK_SPEED_1GB_FULL)
-   ecmd->supported |= SUPPORTED_1000baseT_Full;
+   ecmd->supported |= (ixgbe_isbackplane(hw->phy.media_type)) ?
+  SUPPORTED_1000baseKX_Full :
+  SUPPORTED_1000baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_100_FULL)
ecmd->supported |= ixgbe_isbackplane(hw->phy.media_type) ?
   SUPPORTED_1000baseKX_Full :
-- 
2.7.4



[net-next 2/6] ixgbevf: fix incorrect MAC address on load

2016-08-20 Thread Jeff Kirsher
From: Emil Tantilov 

The PF driver was only receiving the first 4 bytes of the MAC due
to an incorrect size parameter for ixgbevf_write_msg_read_ack()
in ixgbevf_set_rar_vf().

Correct the size by calculating it on a fly for all instances where
we call ixgbevf_write_msg_read_ack()

Signed-off-by: Emil Tantilov 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbevf/vf.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.c 
b/drivers/net/ethernet/intel/ixgbevf/vf.c
index a52f70e..d46ba1d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/vf.c
+++ b/drivers/net/ethernet/intel/ixgbevf/vf.c
@@ -284,7 +284,8 @@ static s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 
index, u8 *addr)
if (addr)
ether_addr_copy(msg_addr, addr);
 
-   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 3);
+   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
+sizeof(msgbuf) / sizeof(u32));
if (!ret_val) {
msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
 
@@ -441,7 +442,8 @@ static s32 ixgbevf_set_rar_vf(struct ixgbe_hw *hw, u32 
index, u8 *addr,
msgbuf[0] = IXGBE_VF_SET_MAC_ADDR;
ether_addr_copy(msg_addr, addr);
 
-   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
+sizeof(msgbuf) / sizeof(u32));
 
msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
 
@@ -551,7 +553,8 @@ static s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, 
int xcast_mode)
msgbuf[0] = IXGBE_VF_UPDATE_XCAST_MODE;
msgbuf[1] = xcast_mode;
 
-   err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+   err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
+sizeof(msgbuf) / sizeof(u32));
if (err)
return err;
 
@@ -588,7 +591,8 @@ static s32 ixgbevf_set_vfta_vf(struct ixgbe_hw *hw, u32 
vlan, u32 vind,
/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
msgbuf[0] |= vlan_on << IXGBE_VT_MSGINFO_SHIFT;
 
-   err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+   err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
+sizeof(msgbuf) / sizeof(u32));
if (err)
goto mbx_err;
 
@@ -791,7 +795,8 @@ static s32 ixgbevf_set_rlpml_vf(struct ixgbe_hw *hw, u16 
max_size)
msgbuf[0] = IXGBE_VF_SET_LPE;
msgbuf[1] = max_size;
 
-   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
+sizeof(msgbuf) / sizeof(u32));
if (ret_val)
return ret_val;
if ((msgbuf[0] & IXGBE_VF_SET_LPE) &&
@@ -837,7 +842,8 @@ static int ixgbevf_negotiate_api_version_vf(struct ixgbe_hw 
*hw, int api)
msg[1] = api;
msg[2] = 0;
 
-   err = ixgbevf_write_msg_read_ack(hw, msg, msg, 3);
+   err = ixgbevf_write_msg_read_ack(hw, msg, msg,
+sizeof(msg) / sizeof(u32));
if (!err) {
msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;
 
@@ -887,7 +893,8 @@ int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int 
*num_tcs,
msg[0] = IXGBE_VF_GET_QUEUE;
msg[1] = msg[2] = msg[3] = msg[4] = 0;
 
-   err = ixgbevf_write_msg_read_ack(hw, msg, msg, 5);
+   err = ixgbevf_write_msg_read_ack(hw, msg, msg,
+sizeof(msg) / sizeof(u32));
if (!err) {
msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;
 
-- 
2.7.4



[net-next 6/6] ixgbe: Add support for new X557 device

2016-08-20 Thread Jeff Kirsher
From: Don Skidmore 

This patch adds support for the new copper device X557.

Signed-off-by: Don Skidmore 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c   | 1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h   | 1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c   | 8 
 4 files changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index b4217f3..3095c24 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -99,6 +99,7 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550T:
case IXGBE_DEV_ID_X550T1:
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
supported = true;
break;
default:
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 5b8819c..d76bc1a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -137,6 +137,7 @@ static const struct pci_device_id ixgbe_pci_tbl[] = {
{PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_SFP_N), board_x550em_a },
{PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_SGMII), board_x550em_a },
{PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_SGMII_L), board_x550em_a },
+   {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_10G_T), board_x550em_a},
{PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_SFP), board_x550em_a },
/* required last entry */
{0, }
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index a59b65f7..31d82e3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -90,6 +90,7 @@
 #define IXGBE_DEV_ID_X550EM_A_SFP_N0x15C4
 #define IXGBE_DEV_ID_X550EM_A_SGMII0x15C6
 #define IXGBE_DEV_ID_X550EM_A_SGMII_L  0x15C7
+#define IXGBE_DEV_ID_X550EM_A_10G_T0x15C8
 #define IXGBE_DEV_ID_X550EM_A_SFP  0x15CE
 
 /* VF Device IDs */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index a8030e0..fb1b819 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -295,6 +295,12 @@ static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR_L:
hw->phy.type = ixgbe_phy_x550em_kr;
break;
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
+   if (hw->bus.lan_id)
+   hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
+   else
+   hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
+   /* Fallthrough */
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
return ixgbe_identify_phy_generic(hw);
@@ -2500,6 +2506,7 @@ static enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
media_type = ixgbe_media_type_copper;
break;
default:
@@ -2560,6 +2567,7 @@ static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_X_10G_T:
case IXGBE_DEV_ID_X550EM_A_SGMII:
case IXGBE_DEV_ID_X550EM_A_SGMII_L:
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
case IXGBE_DEV_ID_X550EM_A_SFP:
/* Config MDIO clock speed before the first MDIO PHY access */
hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-- 
2.7.4



[net-next 5/6] ixgbe: add device to MDIO speed setting

2016-08-20 Thread Jeff Kirsher
From: Don Skidmore 

This shouldn't matter as nothing should be attached still to be
consisted control MDIO speed for these devices as well.

Signed-off-by: Don Skidmore 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 45ad6b1..a8030e0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -2558,6 +2558,8 @@ static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
 
switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_SFP:
/* Config MDIO clock speed before the first MDIO PHY access */
hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-- 
2.7.4



[net-next 0/6][pull request] 10GbE Intel Wired LAN Driver Updates 2016-08-20

2016-08-20 Thread Jeff Kirsher
This series contains updates to ixgbe and ixgbevf.

Veola fixes how the backplane reports the media in ethtool, as KR, KX or
KX4 based on the backplane interface present.

Emil fixes ixgbevf since an incorrect size parameter for
ixgbevf_write_msg_read_ack() ended up only giving the PF the first 4
bytes of the MAC address, so correct the size by calculating it on the
fly for all instances where we call ixgbevf_write_msg_read_ack().  Added
geneve receive offload support for x550em_a.

Don fixes the LED interface for x557 since it uses a different interface.
Added support for the new x557 copper device.

The following are changes since commit 8238ac0ce27b9537a4c161e0382abfc613ee577b:
  Merge branch 'tun-cleanups'
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 10GbE

Don Skidmore (3):
  ixgbe: Fix led interface for X557 devices
  ixgbe: add device to MDIO speed setting
  ixgbe: Add support for new X557 device

Emil Tantilov (2):
  ixgbevf: fix incorrect MAC address on load
  ixgbe: add support for geneve Rx offload

Veola Nazareth (1):
  ixgbe: report correct media type for KR, KX and KX4 interfaces

 drivers/net/ethernet/intel/ixgbe/ixgbe.h |   4 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_common.c  |   1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |   4 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c| 175 ---
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h|  11 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c|  62 +++-
 drivers/net/ethernet/intel/ixgbevf/vf.c  |  21 ++-
 7 files changed, 217 insertions(+), 61 deletions(-)

-- 
2.7.4



[net-next 4/6] ixgbe: Fix led interface for X557 devices

2016-08-20 Thread Jeff Kirsher
From: Don Skidmore 

The X557 devices use a different interface to the LED for the port.
This patch reflect that change.

Signed-off-by: Don Skidmore 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h |  3 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 52 +--
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 5ff91b8..a59b65f7 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -1830,6 +1830,9 @@ enum {
 #define IXGBE_LED_IVRT(_i)   IXGBE_LED_OFFSET(IXGBE_LED_IVRT_BASE, _i)
 #define IXGBE_LED_BLINK(_i)  IXGBE_LED_OFFSET(IXGBE_LED_BLINK_BASE, _i)
 #define IXGBE_LED_MODE_MASK(_i)  IXGBE_LED_OFFSET(IXGBE_LED_MODE_MASK_BASE, _i)
+#define IXGBE_X557_LED_MANUAL_SET_MASK BIT(8)
+#define IXGBE_X557_MAX_LED_INDEX   3
+#define IXGBE_X557_LED_PROVISIONING0xC430
 
 /* LED modes */
 #define IXGBE_LED_LINK_UP   0x0
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 4716ca4..45ad6b1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -2114,6 +2114,50 @@ static s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
return ixgbe_enable_lasi_ext_t_x550em(hw);
 }
 
+/**
+ *  ixgbe_led_on_t_x550em - Turns on the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @led_idx: led number to turn on
+ **/
+s32 ixgbe_led_on_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+   u16 phy_data;
+
+   if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+   return IXGBE_ERR_PARAM;
+
+   /* To turn on the LED, set mode to ON. */
+   hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, _data);
+   phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
+   hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+   return 0;
+}
+
+/**
+ *  ixgbe_led_off_t_x550em - Turns off the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @led_idx: led number to turn off
+ **/
+s32 ixgbe_led_off_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+   u16 phy_data;
+
+   if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+   return IXGBE_ERR_PARAM;
+
+   /* To turn on the LED, set mode to ON. */
+   hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, _data);
+   phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
+   hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+   return 0;
+}
+
 /** ixgbe_get_lcd_x550em - Determine lowest common denominator
  *  @hw: pointer to hardware structure
  *  @lcd_speed: pointer to lowest common link speed
@@ -2853,8 +2897,6 @@ static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
.write_analog_reg8  = NULL, \
.set_rxpba  = _set_rxpba_generic, \
.check_link = _check_mac_link_generic, \
-   .led_on = _led_on_generic, \
-   .led_off= _led_off_generic, \
.blink_led_start= _blink_led_start_X540, \
.blink_led_stop = _blink_led_stop_X540, \
.set_rar= _set_rar_generic, \
@@ -2886,6 +2928,8 @@ static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
 
 static const struct ixgbe_mac_operations mac_ops_X550 = {
X550_COMMON_MAC
+   .led_on = ixgbe_led_on_generic,
+   .led_off= ixgbe_led_off_generic,
.reset_hw   = _reset_hw_X540,
.get_media_type = _get_media_type_X540,
.get_san_mac_addr   = _get_san_mac_addr_generic,
@@ -2904,6 +2948,8 @@ static const struct ixgbe_mac_operations mac_ops_X550 = {
 
 static const struct ixgbe_mac_operations mac_ops_X550EM_x = {
X550_COMMON_MAC
+   .led_on = ixgbe_led_on_t_x550em,
+   .led_off= ixgbe_led_off_t_x550em,
.reset_hw   = _reset_hw_X550em,
.get_media_type = _get_media_type_X550em,
.get_san_mac_addr   = NULL,
@@ -2922,6 +2968,8 @@ static const struct ixgbe_mac_operations mac_ops_X550EM_x 
= {
 
 static struct ixgbe_mac_operations mac_ops_x550em_a = {
X550_COMMON_MAC
+   .led_on = ixgbe_led_on_t_x550em,
+ 

[net-next 3/6] ixgbe: add support for geneve Rx offload

2016-08-20 Thread Jeff Kirsher
From: Emil Tantilov 

Add geneve Rx offload support for x550em_a.

The implementation follows the vxlan code with the lower 16 bits of
the VXLANCTRL register holding the UDP port for VXLAN and the upper
for Geneve.

Disabled NFS filters in the RFCTL register which allows us to simplify
the check for VXLAN and Geneve packets in ixgbe_rx_checksum().

Removed vxlan from the name of the callback functions and replaced it
with udp_tunnel which is more in line with the new API.

Signed-off-by: Emil Tantilov 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h  |   4 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 174 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h |   7 ++
 3 files changed, 134 insertions(+), 51 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 5628e2d..33c0250 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -645,6 +645,7 @@ struct ixgbe_adapter {
 #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED BIT(25)
 #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26)
 #define IXGBE_FLAG_DCB_CAPABLE BIT(27)
+#define IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE  BIT(28)
 
u32 flags2;
 #define IXGBE_FLAG2_RSC_CAPABLEBIT(0)
@@ -658,7 +659,7 @@ struct ixgbe_adapter {
 #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP BIT(9)
 #define IXGBE_FLAG2_PTP_PPS_ENABLEDBIT(10)
 #define IXGBE_FLAG2_PHY_INTERRUPT  BIT(11)
-#define IXGBE_FLAG2_VXLAN_REREG_NEEDED BIT(12)
+#define IXGBE_FLAG2_UDP_TUN_REREG_NEEDED   BIT(12)
 #define IXGBE_FLAG2_VLAN_PROMISC   BIT(13)
 
/* Tx fast path data */
@@ -672,6 +673,7 @@ struct ixgbe_adapter {
 
/* Port number used to identify VXLAN traffic */
__be16 vxlan_port;
+   __be16 geneve_port;
 
/* TX */
struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] cacheline_aligned_in_smp;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 6bf131f..5b8819c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1495,7 +1495,6 @@ static inline void ixgbe_rx_checksum(struct ixgbe_ring 
*ring,
 struct sk_buff *skb)
 {
__le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info;
-   __le16 hdr_info = rx_desc->wb.lower.lo_dword.hs_rss.hdr_info;
bool encap_pkt = false;
 
skb_checksum_none_assert(skb);
@@ -1504,8 +1503,8 @@ static inline void ixgbe_rx_checksum(struct ixgbe_ring 
*ring,
if (!(ring->netdev->features & NETIF_F_RXCSUM))
return;
 
-   if ((pkt_info & cpu_to_le16(IXGBE_RXDADV_PKTTYPE_VXLAN)) &&
-   (hdr_info & cpu_to_le16(IXGBE_RXDADV_PKTTYPE_TUNNEL >> 16))) {
+   /* check for VXLAN and Geneve packets */
+   if (pkt_info & cpu_to_le16(IXGBE_RXDADV_PKTTYPE_VXLAN)) {
encap_pkt = true;
skb->encapsulation = 1;
}
@@ -3922,6 +3921,9 @@ static void ixgbe_configure_rx(struct ixgbe_adapter 
*adapter)
rfctl &= ~IXGBE_RFCTL_RSC_DIS;
if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))
rfctl |= IXGBE_RFCTL_RSC_DIS;
+
+   /* disable NFS filtering */
+   rfctl |= (IXGBE_RFCTL_NFSW_DIS | IXGBE_RFCTL_NFSR_DIS);
IXGBE_WRITE_REG(hw, IXGBE_RFCTL, rfctl);
 
/* Program registers for the distribution of queues */
@@ -4586,18 +4588,23 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter 
*adapter)
}
 }
 
-static void ixgbe_clear_vxlan_port(struct ixgbe_adapter *adapter)
+static void ixgbe_clear_udp_tunnel_port(struct ixgbe_adapter *adapter, u32 
mask)
 {
-   switch (adapter->hw.mac.type) {
-   case ixgbe_mac_X550:
-   case ixgbe_mac_X550EM_x:
-   case ixgbe_mac_x550em_a:
-   IXGBE_WRITE_REG(>hw, IXGBE_VXLANCTRL, 0);
+   struct ixgbe_hw *hw = >hw;
+   u32 vxlanctrl;
+
+   if (!(adapter->flags & (IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE |
+   IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE)))
+   return;
+
+   vxlanctrl = IXGBE_READ_REG(hw, IXGBE_VXLANCTRL) && ~mask;
+   IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, vxlanctrl);
+
+   if (mask & IXGBE_VXLANCTRL_VXLAN_UDPPORT_MASK)
adapter->vxlan_port = 0;
-   break;
-   default:
-   break;
-   }
+
+   if (mask & IXGBE_VXLANCTRL_GENEVE_UDPPORT_MASK)
+   adapter->geneve_port = 0;
 }
 
 #ifdef CONFIG_IXGBE_DCB
@@ -5711,8 +5718,10 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)
if (fwsm & IXGBE_FWSM_TS_ENABLED)
adapter->flags2 |= 

Re: [PATCH] wan-cosa: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread David Miller
From: Christophe JAILLET 
Date: Sat, 20 Aug 2016 10:42:54 +0200

> Le 20/08/2016 à 10:25, SF Markus Elfring a écrit :
>> @@ -875,16 +875,10 @@ static ssize_t cosa_write(struct file *file,
>>  if (count > COSA_MTU)
>>  count = COSA_MTU;
>>  
>> -/* Allocate the buffer */
>> -kbuf = kmalloc(count, GFP_KERNEL|GFP_DMA);
> In this case, 'memdup_user()' has a different meaning, as GFP_DMA will
> no more be used for this memory allocation.

Agreed, this transformation is not equivalent.

Markus, please do not make these changes so blindly.


Re: [PATCH 0/2] tun: Fine-tuning for update_filter()

2016-08-20 Thread David Miller
From: SF Markus Elfring 
Date: Sat, 20 Aug 2016 09:27:39 +0200

> A few update suggestions were taken into account
> from static source code analysis.

Series applied.


Re: [net-next 00/15][pull request] 40GbE Intel Wired LAN Driver Updates 2016-08-19

2016-08-20 Thread David Miller
From: Jeff Kirsher 
Date: Fri, 19 Aug 2016 23:19:36 -0700

> This series contains updates to i40e and i40evf only.

Pulled, thanks Jeff.


Re: [net-next PATCH] ethtool: Add support for SCTP verification tag in Rx NFC

2016-08-20 Thread Alexander Duyck
On Sat, Aug 20, 2016 at 5:21 PM, Ben Hutchings  wrote:
> On Fri, 2016-08-19 at 14:32 -0700, Alexander Duyck wrote:
>> The i40e hardware has support for SCTP filtering via Rx NFC however the
>> default configuration expects us to include the verification tag as a part
>> of the filter.  In order to support that I need to be able to transfer that
>> data through the ethtool interface via a new structure.
>>
>> This patch adds a new structure to allow us to pass the verification tag
>> for IPv4 or IPv6 SCTP traffic.
> [...]
>
> This looks like an incompatible ABI change.  I suppose it could be OK
> if no drivers implemented flow steering for SCTP using the previously
> specified structure, but have you checked that that is the case?
>
> Ben.

Well the structure itself matches the TCP flow spec for the TCP flow
sized portion.  All I am doing with this patch is adding an extension
to that which is still confined to the 52 byte limit of the flow
union.  The net result should be that the new value will appear masked
if anything using the new specifier receives a rule using the old
definition and for anything using the new flow spec that sends to the
old code the extra value will be ignored.  I can look into double
checking the behavior to make certain I have that right on Monday.

One thing I could do if you would like would be to spin up another
patch to force the kernel to return -EINVAL if we are masking in
fields that are out of bounds for the flow specification.  That way we
can handle this  a bit more concisely in the future should we end up
having to extend any other flow specifications.

- Alex


Re: [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()

2016-08-20 Thread Julian Calaby
Hi Marcus,

On Sun, Aug 21, 2016 at 2:46 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Sat, 20 Aug 2016 18:21:29 +0200
>
> Remove a jump label which is unneeded in this function at the end.
>
> Signed-off-by: Markus Elfring 
> ---
>  drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c 
> b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
> index 4e271f9..5942917 100644
> --- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
> +++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
> @@ -3835,14 +3835,12 @@ static int prism2_ioctl_priv_hostapd(local_info_t 
> *local, struct iw_point *p)
> }
>
> if (ret == 1 || !ap_ioctl) {
> -   if (copy_to_user(p->pointer, param, p->length)) {
> +   if (copy_to_user(p->pointer, param, p->length))
> ret = -EFAULT;
> -   goto out;
> -   } else if (ap_ioctl)
> +   else if (ap_ioctl)
> ret = 0;
> }
>
> - out:

Does this change make any difference to the compiled code?

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [net-next PATCH] ethtool: Add support for SCTP verification tag in Rx NFC

2016-08-20 Thread Ben Hutchings
On Fri, 2016-08-19 at 14:32 -0700, Alexander Duyck wrote:
> The i40e hardware has support for SCTP filtering via Rx NFC however the
> default configuration expects us to include the verification tag as a part
> of the filter.  In order to support that I need to be able to transfer that
> data through the ethtool interface via a new structure.
> 
> This patch adds a new structure to allow us to pass the verification tag
> for IPv4 or IPv6 SCTP traffic.
[...]

This looks like an incompatible ABI change.  I suppose it could be OK
if no drivers implemented flow steering for SCTP using the previously
specified structure, but have you checked that that is the case?

Ben.

-- 
Ben Hutchings
It's easier to fight for one's principles than to live up to them.


signature.asc
Description: This is a digitally signed message part


GOOD NEWS.

2016-08-20 Thread Bussiness Alert. X
Dear Sir/Ma
By this email I am checking the possibility of going into confidentiality 
partnership with you to facilitate and provide  guidance for investment of 
funds from overseas.
I run oil and gas businesses in Gabon and Angola, and currently have access to 
high-net-worth individuals who are  interested in accessing the foreign 
economic opportunities through private investments in real estate or other 
businesses.
Please contact me for details:hans.kkre...@gmail.com

Hans Kresic.


Re: [for-next 0/30][PULL request] Mellanox mlx5 core driver updates 2016-08-20

2016-08-20 Thread David Miller

30 patches is way too much to submit at one time and puts an
undue burdon upon potential reviewers of your work.

Please only submit a reasonable amount of patches at one time,
10 to 15 at a maximum.

Thanks.


Re: [PATCH v2 3/4] net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC

2016-08-20 Thread Joachim Eastwood
Hi Martin,

On 20 August 2016 at 11:35, Martin Blumenstingl
 wrote:
> The Ethernet controller available in Meson8b and GXBB SoCs is a Synopsys
> DesignWare MAC IP core which is already supported by the stmmac driver.
>
> In addition to the standard stmmac driver some Meson8b / GXBB specific
> registers have to be configured for the PHY clocks. These SoC specific
> registers are called PRG_ETHERNET_ADDR0 and PRG_ETHERNET_ADDR1 in the
> datasheet.
> These registers are not backwards compatible with those on Meson 6b,
> which is why a new glue driver is introduced. This worked for many
> boards because the bootloader programs the PRG_ETHERNET registers
> correctly. Additionally the meson6-dwmac driver only sets bit 1 of
> PRG_ETHERNET_ADDR0 which (according to the datasheet) is only used
> during reset.
>
> Currently all configuration values can be determined automatically,
> based on the configured phy-mode (which is mandatory for the stmmac
> driver). If required the tx-delay and the mux clock (so it supports
> the MPLL2 clock as well) can be made configurable in the future.
>
> Signed-off-by: Martin Blumenstingl 
> Tested-by: Kevin Hilman 
> ---
>  drivers/net/ethernet/stmicro/stmmac/Makefile   |   2 +-
>  .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c| 329 
> +
>  2 files changed, 330 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c



> +static int meson8b_dwmac_probe(struct platform_device *pdev)
> +{
> +   struct plat_stmmacenet_data *plat_dat;
> +   struct stmmac_resources stmmac_res;
> +   struct resource *res;
> +   struct meson8b_dwmac *dwmac;
> +   int ret;
> +
> +   ret = stmmac_get_platform_resources(pdev, _res);
> +   if (ret)
> +   return ret;
> +
> +   plat_dat = stmmac_probe_config_dt(pdev, _res.mac);
> +   if (IS_ERR(plat_dat))
> +   return PTR_ERR(plat_dat);
> +
> +   dwmac = devm_kzalloc(>dev, sizeof(*dwmac), GFP_KERNEL);
> +   if (!dwmac)
> +   return -ENOMEM;
> +
> +   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +   if (!res)
> +   return -ENODEV;
> +
> +   dwmac->regs = devm_ioremap_resource(>dev, res);
> +   if (IS_ERR(dwmac->regs))
> +   return PTR_ERR(dwmac->regs);
> +
> +   dwmac->pdev = pdev;
> +   dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node);
> +   if (dwmac->phy_mode < 0) {
> +   dev_err(>dev, "missing phy-mode property\n");
> +   return -EINVAL;
> +   }
> +
> +   ret = meson8b_init_clk(dwmac);
> +   if (ret)
> +   return ret;
> +
> +   ret = meson8b_init_prg_eth(dwmac);
> +   if (ret)
> +   return ret;
> +
> +   plat_dat->bsp_priv = dwmac;
> +
> +   platform_set_drvdata(pdev, dwmac);

This will not work. The main stmmac driver already uses the driver_data field.
See: 
http://lxr.free-electrons.com/source/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c#L3218


> +   return stmmac_dvr_probe(>dev, plat_dat, _res);

So calling stmmac_dvr_probe here will overwrite the driver_data field.


> +}
> +
> +static int meson8b_dwmac_remove(struct platform_device *pdev)
> +{
> +   struct meson8b_dwmac *dwmac = platform_get_drvdata(pdev);
> +
> +   clk_disable_unprepare(dwmac->m25_div_clk);

Did you test this code? I am pretty sure it will blow up given that
driver_data is not set to what you expect.

To get your meson8b_dwmac struct you must retrieve it from plat_dat->bsp_priv.


I have some code for a helper to retrieve bsp_priv that I have meant
to sent to the ML for a while now.
See: 
https://github.com/manabian/linux-lpc/commit/c3e155a6e38b9634e4e61aa4eeb4602ede7e44a6

Feel free to add it to your patch set if you want.

Alternatively take a look at the remove function from dwmac-stm32 here:
https://patchwork.ozlabs.org/patch/619816/


> +
> +   return stmmac_pltfr_remove(pdev);
> +}


regards,
Joachim Eastwood


[PATCH net-next 05/30] net/mlx5: Pages management commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created Pages management
commands layout, and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 .../net/ethernet/mellanox/mlx5/core/pagealloc.c| 165 -
 1 file changed, 58 insertions(+), 107 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
index 32dea35..7bfac21 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
@@ -44,12 +44,6 @@ enum {
MLX5_PAGES_TAKE = 2
 };
 
-enum {
-   MLX5_BOOT_PAGES = 1,
-   MLX5_INIT_PAGES = 2,
-   MLX5_POST_INIT_PAGES= 3
-};
-
 struct mlx5_pages_req {
struct mlx5_core_dev *dev;
u16 func_id;
@@ -67,33 +61,6 @@ struct fw_page {
unsignedfree_count;
 };
 
-struct mlx5_query_pages_inbox {
-   struct mlx5_inbox_hdr   hdr;
-   u8  rsvd[8];
-};
-
-struct mlx5_query_pages_outbox {
-   struct mlx5_outbox_hdr  hdr;
-   __be16  rsvd;
-   __be16  func_id;
-   __be32  num_pages;
-};
-
-struct mlx5_manage_pages_inbox {
-   struct mlx5_inbox_hdr   hdr;
-   __be16  rsvd;
-   __be16  func_id;
-   __be32  num_entries;
-   __be64  pas[0];
-};
-
-struct mlx5_manage_pages_outbox {
-   struct mlx5_outbox_hdr  hdr;
-   __be32  num_entries;
-   u8  rsvd[4];
-   __be64  pas[0];
-};
-
 enum {
MAX_RECLAIM_TIME_MSECS  = 5000,
MAX_RECLAIM_VFS_PAGES_TIME_MSECS = 2 * 1000 * 60,
@@ -167,24 +134,22 @@ static struct fw_page *find_fw_page(struct mlx5_core_dev 
*dev, u64 addr)
 static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
s32 *npages, int boot)
 {
-   struct mlx5_query_pages_inbox   in;
-   struct mlx5_query_pages_outbox  out;
+   u32 out[MLX5_ST_SZ_DW(query_pages_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(query_pages_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_PAGES);
-   in.hdr.opmod = boot ? cpu_to_be16(MLX5_BOOT_PAGES) : 
cpu_to_be16(MLX5_INIT_PAGES);
+   MLX5_SET(query_pages_in, in, opcode, MLX5_CMD_OP_QUERY_PAGES);
+   MLX5_SET(query_pages_in, in, op_mod, boot ?
+MLX5_QUERY_PAGES_IN_OP_MOD_BOOT_PAGES :
+MLX5_QUERY_PAGES_IN_OP_MOD_INIT_PAGES);
 
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   err = err ? : mlx5_cmd_status_to_err_v2(out);
if (err)
return err;
 
-   if (out.hdr.status)
-   return mlx5_cmd_status_to_err();
-
-   *npages = be32_to_cpu(out.num_pages);
-   *func_id = be16_to_cpu(out.func_id);
+   *npages = MLX5_GET(query_pages_out, out, num_pages);
+   *func_id = MLX5_GET(query_pages_out, out, function_id);
 
return err;
 }
@@ -280,46 +245,37 @@ out_alloc:
 
 static void page_notify_fail(struct mlx5_core_dev *dev, u16 func_id)
 {
-   struct mlx5_manage_pages_inbox *in;
-   struct mlx5_manage_pages_outbox out;
+   u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(manage_pages_in)]   = {0};
int err;
 
-   in = kzalloc(sizeof(*in), GFP_KERNEL);
-   if (!in)
-   return;
-
-   memset(, 0, sizeof(out));
-   in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
-   in->hdr.opmod = cpu_to_be16(MLX5_PAGES_CANT_GIVE);
-   in->func_id = cpu_to_be16(func_id);
-   err = mlx5_cmd_exec(dev, in, sizeof(*in), , sizeof(out));
-   if (!err)
-   err = mlx5_cmd_status_to_err();
-
+   MLX5_SET(manage_pages_in, in, opcode, MLX5_CMD_OP_MANAGE_PAGES);
+   MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_CANT_GIVE);
+   MLX5_SET(manage_pages_in, in, function_id, func_id);
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   err = err ? : mlx5_cmd_status_to_err_v2(out);
if (err)
-   mlx5_core_warn(dev, "page notify failed\n");
-
-   kfree(in);
+   mlx5_core_warn(dev, "page notify failed func_id(%d) err(%d)\n",
+  func_id, err);
 }
 
 static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
  int notify_fail)
 {
-   struct mlx5_manage_pages_inbox *in;
-   struct mlx5_manage_pages_outbox out;
-   int inlen;
+   u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};
+   int inlen = MLX5_ST_SZ_BYTES(manage_pages_in);
u64 addr;
int 

[PATCH net-next 10/30] {net,IB}/mlx5: Modify QP commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Prior to this patch we assumed that modify QP commands have the
same layout.

In ConnectX-4 for each QP transition there is a specific command
and their layout can vary.

e.g: 2err/2rst commands don't have QP context in their layout and before
this patch we posted the QP context in those commands.

Fortunately the FW only checks the suffix of the commands and executes
them, while ignoring all invalid data sent after the valid command
layout.

This patch removes mlx5_modify_qp_mbox_in and changes
mlx5_core_qp_modify to receive the required transition and QP context
with opt_param_mask if needed.  This way the caller is not required to
provide the command inbox layout and it will be generated automatically.

mlx5_core_qp_modify will generate the command inbox/outbox layouts
according to the requested transition and will fill the requested
parameters.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/hw/mlx5/qp.c  |  22 ++---
 drivers/net/ethernet/mellanox/mlx5/core/qp.c | 124 +--
 include/linux/mlx5/qp.h  |  20 +
 3 files changed, 124 insertions(+), 42 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index d22492f..6261737 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1871,7 +1871,6 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, 
struct mlx5_ib_qp *qp)
 {
struct mlx5_ib_cq *send_cq, *recv_cq;
struct mlx5_ib_qp_base *base = >trans_qp.base;
-   struct mlx5_modify_qp_mbox_in *in;
unsigned long flags;
int err;
 
@@ -1884,16 +1883,12 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, 
struct mlx5_ib_qp *qp)
   >raw_packet_qp.rq.base :
   >trans_qp.base;
 
-   in = kzalloc(sizeof(*in), GFP_KERNEL);
-   if (!in)
-   return;
-
if (qp->state != IB_QPS_RESET) {
if (qp->ibqp.qp_type != IB_QPT_RAW_PACKET) {
mlx5_ib_qp_disable_pagefaults(qp);
err = mlx5_core_qp_modify(dev->mdev,
- MLX5_CMD_OP_2RST_QP, in, 0,
- >mqp);
+ MLX5_CMD_OP_2RST_QP, 0,
+ NULL, >mqp);
} else {
err = modify_raw_packet_qp(dev, qp,
   MLX5_CMD_OP_2RST_QP);
@@ -1935,8 +1930,6 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, 
struct mlx5_ib_qp *qp)
 base->mqp.qpn);
}
 
-   kfree(in);
-
if (qp->create_type == MLX5_QP_KERNEL)
destroy_qp_kernel(dev, qp);
else if (qp->create_type == MLX5_QP_USER)
@@ -2522,7 +2515,6 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
struct mlx5_ib_qp_base *base = >trans_qp.base;
struct mlx5_ib_cq *send_cq, *recv_cq;
struct mlx5_qp_context *context;
-   struct mlx5_modify_qp_mbox_in *in;
struct mlx5_ib_pd *pd;
enum mlx5_qp_state mlx5_cur, mlx5_new;
enum mlx5_qp_optpar optpar;
@@ -2531,11 +2523,10 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
int err;
u16 op;
 
-   in = kzalloc(sizeof(*in), GFP_KERNEL);
-   if (!in)
+   context = kzalloc(sizeof(*context), GFP_KERNEL);
+   if (!context)
return -ENOMEM;
 
-   context = >ctx;
err = to_mlx5_st(ibqp->qp_type);
if (err < 0) {
mlx5_ib_dbg(dev, "unsupported qp type %d\n", ibqp->qp_type);
@@ -2700,12 +2691,11 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
op = optab[mlx5_cur][mlx5_new];
optpar = ib_mask_to_mlx5_opt(attr_mask);
optpar &= opt_mask[mlx5_cur][mlx5_new][mlx5_st];
-   in->optparam = cpu_to_be32(optpar);
 
if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET)
err = modify_raw_packet_qp(dev, qp, op);
else
-   err = mlx5_core_qp_modify(dev->mdev, op, in, sqd_event,
+   err = mlx5_core_qp_modify(dev->mdev, op, optpar, context,
  >mqp);
if (err)
goto out;
@@ -2746,7 +2736,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
}
 
 out:
-   kfree(in);
+   kfree(context);
return err;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/qp.c 
b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
index 36d240c..50875a4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
@@ -335,21 +335,127 @@ int mlx5_core_destroy_qp(struct mlx5_core_dev *dev,
 }
 EXPORT_SYMBOL_GPL(mlx5_core_destroy_qp);
 
-int mlx5_core_qp_modify(struct mlx5_core_dev *dev, u16 operation,
-  

[PATCH net-next 06/30] net/mlx5: EQ commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created EQ commands layout,
and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 18 +++---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c  | 78 ++-
 include/linux/mlx5/device.h   | 74 -
 include/linux/mlx5/driver.h   |  2 +-
 4 files changed, 44 insertions(+), 128 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c 
b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
index 5210d92..58e5518 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
@@ -358,32 +358,32 @@ out:
 static u64 eq_read_field(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
 int index)
 {
-   struct mlx5_query_eq_mbox_out *out;
-   struct mlx5_eq_context *ctx;
+   int outlen = MLX5_ST_SZ_BYTES(query_eq_out);
u64 param = 0;
+   void *ctx;
+   u32 *out;
int err;
 
-   out = kzalloc(sizeof(*out), GFP_KERNEL);
+   out = kzalloc(outlen, GFP_KERNEL);
if (!out)
return param;
 
-   ctx = >ctx;
-
-   err = mlx5_core_eq_query(dev, eq, out, sizeof(*out));
+   err = mlx5_core_eq_query(dev, eq, out, outlen);
if (err) {
mlx5_core_warn(dev, "failed to query eq\n");
goto out;
}
+   ctx = MLX5_ADDR_OF(query_eq_out, out, eq_context_entry);
 
switch (index) {
case EQ_NUM_EQES:
-   param = 1 << ((be32_to_cpu(ctx->log_sz_usr_page) >> 24) & 0x1f);
+   param = 1 << MLX5_GET(eqc, ctx, log_eq_size);
break;
case EQ_INTR:
-   param = ctx->intr;
+   param = MLX5_GET(eqc, ctx, intr);
break;
case EQ_LOG_PG_SZ:
-   param = (ctx->log_page_size & 0x1f) + 12;
+   param = MLX5_GET(eqc, ctx, log_page_size) + 12;
break;
}
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index 0e30602..7141197 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -86,23 +86,16 @@ struct cre_des_eq {
 
 static int mlx5_cmd_destroy_eq(struct mlx5_core_dev *dev, u8 eqn)
 {
-   struct mlx5_destroy_eq_mbox_in in;
-   struct mlx5_destroy_eq_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(destroy_eq_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(destroy_eq_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_EQ);
-   in.eqn = eqn;
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
-   if (!err)
-   goto ex;
+   MLX5_SET(destroy_eq_in, in, opcode, MLX5_CMD_OP_DESTROY_EQ);
+   MLX5_SET(destroy_eq_in, in, eq_number, eqn);
 
-   if (out.hdr.status)
-   err = mlx5_cmd_status_to_err();
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   return err ? : mlx5_cmd_status_to_err_v2(out);
 
-ex:
-   return err;
 }
 
 static struct mlx5_eqe *get_eqe(struct mlx5_eq *eq, u32 entry)
@@ -351,11 +344,13 @@ static void init_eq_buf(struct mlx5_eq *eq)
 int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 
vecidx,
   int nent, u64 mask, const char *name, struct mlx5_uar 
*uar)
 {
+   u32 out[MLX5_ST_SZ_DW(create_eq_out)] = {0};
struct mlx5_priv *priv = >priv;
-   struct mlx5_create_eq_mbox_in *in;
-   struct mlx5_create_eq_mbox_out out;
-   int err;
+   __be64 *pas;
+   void *eqc;
int inlen;
+   u32 *in;
+   int err;
 
eq->nent = roundup_pow_of_two(nent + MLX5_NUM_SPARE_EQE);
eq->cons_index = 0;
@@ -365,35 +360,37 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct 
mlx5_eq *eq, u8 vecidx,
 
init_eq_buf(eq);
 
-   inlen = sizeof(*in) + sizeof(in->pas[0]) * eq->buf.npages;
+   inlen = MLX5_ST_SZ_BYTES(create_eq_in) +
+   MLX5_FLD_SZ_BYTES(create_eq_in, pas[0]) * eq->buf.npages;
+
in = mlx5_vzalloc(inlen);
if (!in) {
err = -ENOMEM;
goto err_buf;
}
-   memset(, 0, sizeof(out));
 
-   mlx5_fill_page_array(>buf, in->pas);
+   pas = (__be64 *)MLX5_ADDR_OF(create_eq_in, in, pas);
+   mlx5_fill_page_array(>buf, pas);
 
-   in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_CREATE_EQ);
-   in->ctx.log_sz_usr_page = cpu_to_be32(ilog2(eq->nent) << 24 | 
uar->index);
-   in->ctx.intr = vecidx;
-   in->ctx.log_page_size = eq->buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT;
-   in->events_mask = cpu_to_be64(mask);
+   MLX5_SET(create_eq_in, in, 

[PATCH net-next 01/30] net/mlx5: Init/Teardown hca commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created Init/Teardown hca
commands layout and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/fw.c | 36 
 include/linux/mlx5/device.h  | 24 ---
 2 files changed, 10 insertions(+), 50 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
index 77fc1aa..56bf520 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
@@ -162,38 +162,22 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
 
 int mlx5_cmd_init_hca(struct mlx5_core_dev *dev)
 {
-   struct mlx5_cmd_init_hca_mbox_in in;
-   struct mlx5_cmd_init_hca_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(init_hca_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(init_hca_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_INIT_HCA);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
-   if (err)
-   return err;
-
-   if (out.hdr.status)
-   err = mlx5_cmd_status_to_err();
-
-   return err;
+   MLX5_SET(init_hca_in, in, opcode, MLX5_CMD_OP_INIT_HCA);
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   return err ? : mlx5_cmd_status_to_err_v2(out);
 }
 
 int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev)
 {
-   struct mlx5_cmd_teardown_hca_mbox_in in;
-   struct mlx5_cmd_teardown_hca_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(teardown_hca_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(teardown_hca_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_TEARDOWN_HCA);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
-   if (err)
-   return err;
-
-   if (out.hdr.status)
-   err = mlx5_cmd_status_to_err();
-
-   return err;
+   MLX5_SET(teardown_hca_in, in, opcode, MLX5_CMD_OP_TEARDOWN_HCA);
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   return err ? : mlx5_cmd_status_to_err_v2(out);
 }
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 0b6d15c..6c343c0 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -455,30 +455,6 @@ struct mlx5_odp_caps {
char reserved2[0xe4];
 };
 
-struct mlx5_cmd_init_hca_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   u8  rsvd0[2];
-   __be16  profile;
-   u8  rsvd1[4];
-};
-
-struct mlx5_cmd_init_hca_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   u8  rsvd[8];
-};
-
-struct mlx5_cmd_teardown_hca_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   u8  rsvd0[2];
-   __be16  profile;
-   u8  rsvd1[4];
-};
-
-struct mlx5_cmd_teardown_hca_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   u8  rsvd[8];
-};
-
 struct mlx5_cmd_layout {
u8  type;
u8  rsvd0[3];
-- 
2.7.4



[PATCH net-next 02/30] net/mlx5: Access register and MAD IFC commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created ACCESS_REG/MAD_IFC
commands layout and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/mad.c  | 42 ++---
 drivers/net/ethernet/mellanox/mlx5/core/port.c | 52 +-
 include/linux/mlx5/device.h| 29 --
 3 files changed, 45 insertions(+), 78 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mad.c 
b/drivers/net/ethernet/mellanox/mlx5/core/mad.c
index 1368dac..13e6afd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mad.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mad.c
@@ -39,36 +39,34 @@
 int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
  u16 opmod, u8 port)
 {
-   struct mlx5_mad_ifc_mbox_in *in = NULL;
-   struct mlx5_mad_ifc_mbox_out *out = NULL;
-   int err;
+   int outlen = MLX5_ST_SZ_BYTES(mad_ifc_out);
+   int inlen = MLX5_ST_SZ_BYTES(mad_ifc_in);
+   int err = -ENOMEM;
+   void *data;
+   void *resp;
+   u32 *out;
+   u32 *in;
 
-   in = kzalloc(sizeof(*in), GFP_KERNEL);
-   if (!in)
-   return -ENOMEM;
-
-   out = kzalloc(sizeof(*out), GFP_KERNEL);
-   if (!out) {
-   err = -ENOMEM;
+   in = kzalloc(inlen, GFP_KERNEL);
+   out = kzalloc(outlen, GFP_KERNEL);
+   if (!in || !out)
goto out;
-   }
 
-   in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MAD_IFC);
-   in->hdr.opmod = cpu_to_be16(opmod);
-   in->port = port;
+   MLX5_SET(mad_ifc_in, in, opcode, MLX5_CMD_OP_MAD_IFC);
+   MLX5_SET(mad_ifc_in, in, op_mod, opmod);
+   MLX5_SET(mad_ifc_in, in, port, port);
 
-   memcpy(in->data, inb, sizeof(in->data));
+   data = MLX5_ADDR_OF(mad_ifc_in, in, mad);
+   memcpy(data, inb, MLX5_FLD_SZ_BYTES(mad_ifc_in, mad));
 
-   err = mlx5_cmd_exec(dev, in, sizeof(*in), out, sizeof(*out));
+   err = mlx5_cmd_exec(dev, in, inlen, out, outlen);
+   err = err ? : mlx5_cmd_status_to_err_v2(out);
if (err)
goto out;
 
-   if (out->hdr.status) {
-   err = mlx5_cmd_status_to_err(>hdr);
-   goto out;
-   }
-
-   memcpy(outb, out->data, sizeof(out->data));
+   resp = MLX5_ADDR_OF(mad_ifc_out, out, response_mad_packet);
+   memcpy(outb, resp,
+  MLX5_FLD_SZ_BYTES(mad_ifc_out, response_mad_packet));
 
 out:
kfree(out);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c 
b/drivers/net/ethernet/mellanox/mlx5/core/port.c
index 752c081..e8324c2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
@@ -38,45 +38,43 @@
 
 int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
 int size_in, void *data_out, int size_out,
-u16 reg_num, int arg, int write)
+u16 reg_id, int arg, int write)
 {
-   struct mlx5_access_reg_mbox_in *in = NULL;
-   struct mlx5_access_reg_mbox_out *out = NULL;
+   int outlen = MLX5_ST_SZ_BYTES(access_register_out) + size_out;
+   int inlen = MLX5_ST_SZ_BYTES(access_register_in) + size_in;
int err = -ENOMEM;
+   u32 *out = NULL;
+   u32 *in = NULL;
+   void *data;
 
-   in = mlx5_vzalloc(sizeof(*in) + size_in);
-   if (!in)
-   return -ENOMEM;
-
-   out = mlx5_vzalloc(sizeof(*out) + size_out);
-   if (!out)
-   goto ex1;
-
-   memcpy(in->data, data_in, size_in);
-   in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ACCESS_REG);
-   in->hdr.opmod = cpu_to_be16(!write);
-   in->arg = cpu_to_be32(arg);
-   in->register_id = cpu_to_be16(reg_num);
-   err = mlx5_cmd_exec(dev, in, sizeof(*in) + size_in, out,
-   sizeof(*out) + size_out);
-   if (err)
-   goto ex2;
+   in = mlx5_vzalloc(inlen);
+   out = mlx5_vzalloc(outlen);
+   if (!in || !out)
+   goto out;
 
-   if (out->hdr.status)
-   err = mlx5_cmd_status_to_err(>hdr);
+   data = MLX5_ADDR_OF(access_register_in, in, register_data);
+   memcpy(data, data_in, size_in);
 
-   if (!err)
-   memcpy(data_out, out->data, size_out);
+   MLX5_SET(access_register_in, in, opcode, MLX5_CMD_OP_ACCESS_REG);
+   MLX5_SET(access_register_in, in, op_mod, !write);
+   MLX5_SET(access_register_in, in, argument, arg);
+   MLX5_SET(access_register_in, in, register_id, reg_id);
+
+   err = mlx5_cmd_exec(dev, in, inlen, out, outlen);
+   err = err ? : mlx5_cmd_status_to_err_v2(out);
+   if (err)
+   goto out;
+
+   data = MLX5_ADDR_OF(access_register_out, out, register_data);
+   memcpy(data_out, data, size_out);
 
-ex2:
+out:
 

[PATCH net-next 07/30] {net,IB}/mlx5: CQ commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created CQ commands layout,
and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/hw/mlx5/cq.c   | 110 -
 drivers/net/ethernet/mellanox/mlx5/core/cq.c  | 113 +-
 drivers/net/ethernet/mellanox/mlx5/core/debugfs.c |  18 ++--
 include/linux/mlx5/cq.h   |   6 +-
 include/linux/mlx5/device.h   |  76 ---
 5 files changed, 122 insertions(+), 201 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
index 308a358..35a9f71 100644
--- a/drivers/infiniband/hw/mlx5/cq.c
+++ b/drivers/infiniband/hw/mlx5/cq.c
@@ -747,14 +747,16 @@ static int alloc_cq_buf(struct mlx5_ib_dev *dev, struct 
mlx5_ib_cq_buf *buf,
 
 static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
  struct ib_ucontext *context, struct mlx5_ib_cq *cq,
- int entries, struct mlx5_create_cq_mbox_in **cqb,
+ int entries, u32 **cqb,
  int *cqe_size, int *index, int *inlen)
 {
struct mlx5_ib_create_cq ucmd;
size_t ucmdlen;
int page_shift;
+   __be64 *pas;
int npages;
int ncont;
+   void *cqc;
int err;
 
ucmdlen =
@@ -792,14 +794,20 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct 
ib_udata *udata,
mlx5_ib_dbg(dev, "addr 0x%llx, size %u, npages %d, page_shift %d, ncont 
%d\n",
ucmd.buf_addr, entries * ucmd.cqe_size, npages, page_shift, 
ncont);
 
-   *inlen = sizeof(**cqb) + sizeof(*(*cqb)->pas) * ncont;
+   *inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
+MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * ncont;
*cqb = mlx5_vzalloc(*inlen);
if (!*cqb) {
err = -ENOMEM;
goto err_db;
}
-   mlx5_ib_populate_pas(dev, cq->buf.umem, page_shift, (*cqb)->pas, 0);
-   (*cqb)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
+
+   pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, *cqb, pas);
+   mlx5_ib_populate_pas(dev, cq->buf.umem, page_shift, pas, 0);
+
+   cqc = MLX5_ADDR_OF(create_cq_in, *cqb, cq_context);
+   MLX5_SET(cqc, cqc, log_page_size,
+page_shift - MLX5_ADAPTER_PAGE_SHIFT);
 
*index = to_mucontext(context)->uuari.uars[0].index;
 
@@ -834,9 +842,10 @@ static void init_cq_buf(struct mlx5_ib_cq *cq, struct 
mlx5_ib_cq_buf *buf)
 
 static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
int entries, int cqe_size,
-   struct mlx5_create_cq_mbox_in **cqb,
-   int *index, int *inlen)
+   u32 **cqb, int *index, int *inlen)
 {
+   __be64 *pas;
+   void *cqc;
int err;
 
err = mlx5_db_alloc(dev->mdev, >db);
@@ -853,15 +862,21 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, 
struct mlx5_ib_cq *cq,
 
init_cq_buf(cq, >buf);
 
-   *inlen = sizeof(**cqb) + sizeof(*(*cqb)->pas) * cq->buf.buf.npages;
+   *inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
+MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * cq->buf.buf.npages;
*cqb = mlx5_vzalloc(*inlen);
if (!*cqb) {
err = -ENOMEM;
goto err_buf;
}
-   mlx5_fill_page_array(>buf.buf, (*cqb)->pas);
 
-   (*cqb)->ctx.log_pg_sz = cq->buf.buf.page_shift - 
MLX5_ADAPTER_PAGE_SHIFT;
+   pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, *cqb, pas);
+   mlx5_fill_page_array(>buf.buf, pas);
+
+   cqc = MLX5_ADDR_OF(create_cq_in, *cqb, cq_context);
+   MLX5_SET(cqc, cqc, log_page_size,
+cq->buf.buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+
*index = dev->mdev->priv.uuari.uars[0].index;
 
return 0;
@@ -895,11 +910,12 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
 {
int entries = attr->cqe;
int vector = attr->comp_vector;
-   struct mlx5_create_cq_mbox_in *cqb = NULL;
struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_ib_cq *cq;
int uninitialized_var(index);
int uninitialized_var(inlen);
+   u32 *cqb = NULL;
+   void *cqc;
int cqe_size;
unsigned int irqn;
int eqn;
@@ -945,19 +961,20 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
INIT_WORK(>notify_work, notify_soft_wc_handler);
}
 
-   cq->cqe_size = cqe_size;
-   cqb->ctx.cqe_sz_flags = cqe_sz_to_mlx_sz(cqe_size) << 5;
-
-   if (cq->create_flags & IB_CQ_FLAGS_IGNORE_OVERRUN)
-   cqb->ctx.cqe_sz_flags |= (1 << 1);
-
-   cqb->ctx.log_sz_usr_page = cpu_to_be32((ilog2(entries) << 24) | index);
err = 

[PATCH net-next 27/30] net/mlx5: Vport LAG creation support

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

Add interfaces for issuing CREATE_VPORT_LAG and
DESTROY_VPORT_LAG commands.

Used for receiving PF1's eth traffic on PF0's
root ft.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/lag.c | 22 ++
 include/linux/mlx5/driver.h   |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c 
b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
index 3cb570a..5fe320c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -110,6 +110,28 @@ static int mlx5_cmd_destroy_lag(struct mlx5_core_dev *dev)
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
 }
 
+int mlx5_cmd_create_vport_lag(struct mlx5_core_dev *dev)
+{
+   u32  in[MLX5_ST_SZ_DW(create_vport_lag_in)]  = {0};
+   u32 out[MLX5_ST_SZ_DW(create_vport_lag_out)] = {0};
+
+   MLX5_SET(create_vport_lag_in, in, opcode, MLX5_CMD_OP_CREATE_VPORT_LAG);
+
+   return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
+EXPORT_SYMBOL(mlx5_cmd_create_vport_lag);
+
+int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev)
+{
+   u32  in[MLX5_ST_SZ_DW(destroy_vport_lag_in)]  = {0};
+   u32 out[MLX5_ST_SZ_DW(destroy_vport_lag_out)] = {0};
+
+   MLX5_SET(destroy_vport_lag_in, in, opcode, 
MLX5_CMD_OP_DESTROY_VPORT_LAG);
+
+   return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
+EXPORT_SYMBOL(mlx5_cmd_destroy_vport_lag);
+
 static struct mlx5_lag *mlx5_lag_dev_get(struct mlx5_core_dev *dev)
 {
return dev->priv.lag;
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index c568dd9..5cb9fa7 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -944,6 +944,8 @@ int mlx5_register_interface(struct mlx5_interface *intf);
 void mlx5_unregister_interface(struct mlx5_interface *intf);
 int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id);
 
+int mlx5_cmd_create_vport_lag(struct mlx5_core_dev *dev);
+int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev);
 bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
 struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);
 
-- 
2.7.4



[PATCH net-next 18/30] net/mlx5: Expose mlx5e_link_mode

2016-08-20 Thread Saeed Mahameed
From: Noa Osherovich 

The mlx5e_link_mode enumeration will also be used in mlx5_ib for RoCE.
This patch moves the enumeration to the mlx5 driver port header file.

Signed-off-by: Noa Osherovich 
Signed-off-by: Eran Ben Elisha 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h | 34 
 include/linux/mlx5/port.h| 33 +++
 2 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h 
b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 1b495ef..61902b1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -651,40 +651,6 @@ struct mlx5e_priv {
void  *ppriv;
 };
 
-enum mlx5e_link_mode {
-   MLX5E_1000BASE_CX_SGMII  = 0,
-   MLX5E_1000BASE_KX= 1,
-   MLX5E_10GBASE_CX4= 2,
-   MLX5E_10GBASE_KX4= 3,
-   MLX5E_10GBASE_KR = 4,
-   MLX5E_20GBASE_KR2= 5,
-   MLX5E_40GBASE_CR4= 6,
-   MLX5E_40GBASE_KR4= 7,
-   MLX5E_56GBASE_R4 = 8,
-   MLX5E_10GBASE_CR = 12,
-   MLX5E_10GBASE_SR = 13,
-   MLX5E_10GBASE_ER = 14,
-   MLX5E_40GBASE_SR4= 15,
-   MLX5E_40GBASE_LR4= 16,
-   MLX5E_50GBASE_SR2= 18,
-   MLX5E_100GBASE_CR4   = 20,
-   MLX5E_100GBASE_SR4   = 21,
-   MLX5E_100GBASE_KR4   = 22,
-   MLX5E_100GBASE_LR4   = 23,
-   MLX5E_100BASE_TX = 24,
-   MLX5E_1000BASE_T = 25,
-   MLX5E_10GBASE_T  = 26,
-   MLX5E_25GBASE_CR = 27,
-   MLX5E_25GBASE_KR = 28,
-   MLX5E_25GBASE_SR = 29,
-   MLX5E_50GBASE_CR2= 30,
-   MLX5E_50GBASE_KR2= 31,
-   MLX5E_LINK_MODES_NUMBER,
-};
-
-#define MLX5E_PROT_MASK(link_mode) (1 << link_mode)
-
-
 void mlx5e_build_ptys2ethtool_map(void);
 
 void mlx5e_send_nop(struct mlx5e_sq *sq, bool notify_hw);
diff --git a/include/linux/mlx5/port.h b/include/linux/mlx5/port.h
index e3012cc..6f876a4 100644
--- a/include/linux/mlx5/port.h
+++ b/include/linux/mlx5/port.h
@@ -61,6 +61,39 @@ enum mlx5_an_status {
 #define MLX5_I2C_ADDR_HIGH 0x51
 #define MLX5_EEPROM_PAGE_LENGTH256
 
+enum mlx5e_link_mode {
+   MLX5E_1000BASE_CX_SGMII  = 0,
+   MLX5E_1000BASE_KX= 1,
+   MLX5E_10GBASE_CX4= 2,
+   MLX5E_10GBASE_KX4= 3,
+   MLX5E_10GBASE_KR = 4,
+   MLX5E_20GBASE_KR2= 5,
+   MLX5E_40GBASE_CR4= 6,
+   MLX5E_40GBASE_KR4= 7,
+   MLX5E_56GBASE_R4 = 8,
+   MLX5E_10GBASE_CR = 12,
+   MLX5E_10GBASE_SR = 13,
+   MLX5E_10GBASE_ER = 14,
+   MLX5E_40GBASE_SR4= 15,
+   MLX5E_40GBASE_LR4= 16,
+   MLX5E_50GBASE_SR2= 18,
+   MLX5E_100GBASE_CR4   = 20,
+   MLX5E_100GBASE_SR4   = 21,
+   MLX5E_100GBASE_KR4   = 22,
+   MLX5E_100GBASE_LR4   = 23,
+   MLX5E_100BASE_TX = 24,
+   MLX5E_1000BASE_T = 25,
+   MLX5E_10GBASE_T  = 26,
+   MLX5E_25GBASE_CR = 27,
+   MLX5E_25GBASE_KR = 28,
+   MLX5E_25GBASE_SR = 29,
+   MLX5E_50GBASE_CR2= 30,
+   MLX5E_50GBASE_KR2= 31,
+   MLX5E_LINK_MODES_NUMBER,
+};
+
+#define MLX5E_PROT_MASK(link_mode) (1 << link_mode)
+
 int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps);
 int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
 int ptys_size, int proto_mask, u8 local_port);
-- 
2.7.4



[PATCH net-next 12/30] net/mlx5: Improve driver log messages

2016-08-20 Thread Saeed Mahameed
Remove duplicate pci dev name printing in mlx5_core_err.
Use mlx5_core_{warn,info,err} where possible to have the pci info in the
driver log messages.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Parvi Kaustubhi 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   |  4 ++--
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  | 26 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c  | 18 ---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 11 -
 .../net/ethernet/mellanox/mlx5/core/mlx5_core.h|  4 ++--
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c|  7 +++---
 6 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 1c7d8b8..681c12c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -416,8 +416,8 @@ int mlx5e_vport_rep_load(struct mlx5_eswitch *esw,
 {
rep->priv_data = mlx5e_create_netdev(esw->dev, _rep_profile, rep);
if (!rep->priv_data) {
-   pr_warn("Failed to create representor for vport %d\n",
-   rep->vport);
+   mlx5_core_warn(esw->dev, "Failed to create representor for 
vport %d\n",
+  rep->vport);
return -EINVAL;
}
return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 0a364bf..7c493599 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -306,7 +306,7 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 
vport, bool rx_rule,
 
spec = mlx5_vzalloc(sizeof(*spec));
if (!spec) {
-   pr_warn("FDB: Failed to alloc match parameters\n");
+   esw_warn(esw->dev, "FDB: Failed to alloc match parameters\n");
return NULL;
}
dmac_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
@@ -340,8 +340,8 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 
vport, bool rx_rule,
   MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
   0, );
if (IS_ERR(flow_rule)) {
-   pr_warn(
-   "FDB: Failed to add flow rule: dmac_v(%pM) dmac_c(%pM) 
-> vport(%d), err(%ld)\n",
+   esw_warn(esw->dev,
+"FDB: Failed to add flow rule: dmac_v(%pM) dmac_c(%pM) 
-> vport(%d), err(%ld)\n",
 dmac_v, dmac_c, vport, PTR_ERR(flow_rule));
flow_rule = NULL;
}
@@ -1318,8 +1318,9 @@ static int esw_vport_ingress_config(struct mlx5_eswitch 
*esw,
   0, NULL);
if (IS_ERR(vport->ingress.allow_rule)) {
err = PTR_ERR(vport->ingress.allow_rule);
-   pr_warn("vport[%d] configure ingress allow rule, err(%d)\n",
-   vport->vport, err);
+   esw_warn(esw->dev,
+"vport[%d] configure ingress allow rule, err(%d)\n",
+vport->vport, err);
vport->ingress.allow_rule = NULL;
goto out;
}
@@ -1331,8 +1332,9 @@ static int esw_vport_ingress_config(struct mlx5_eswitch 
*esw,
   0, NULL);
if (IS_ERR(vport->ingress.drop_rule)) {
err = PTR_ERR(vport->ingress.drop_rule);
-   pr_warn("vport[%d] configure ingress drop rule, err(%d)\n",
-   vport->vport, err);
+   esw_warn(esw->dev,
+"vport[%d] configure ingress drop rule, err(%d)\n",
+vport->vport, err);
vport->ingress.drop_rule = NULL;
goto out;
}
@@ -1384,8 +1386,9 @@ static int esw_vport_egress_config(struct mlx5_eswitch 
*esw,
   0, NULL);
if (IS_ERR(vport->egress.allowed_vlan)) {
err = PTR_ERR(vport->egress.allowed_vlan);
-   pr_warn("vport[%d] configure egress allowed vlan rule failed, 
err(%d)\n",
-   vport->vport, err);
+   esw_warn(esw->dev,
+"vport[%d] configure egress allowed vlan rule failed, 
err(%d)\n",
+vport->vport, err);
vport->egress.allowed_vlan = NULL;
goto out;
}
@@ -1398,8 +1401,9 @@ static int esw_vport_egress_config(struct mlx5_eswitch 
*esw,
   0, NULL);
if (IS_ERR(vport->egress.drop_rule)) {
err = PTR_ERR(vport->egress.drop_rule);
-   pr_warn("vport[%d] configure egress drop rule failed, 
err(%d)\n",
-   vport->vport, 

[PATCH net-next 09/30] {net,IB}/mlx5: QP/XRCD commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created QP/XRCD commands layout
amd use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/hw/mlx5/qp.c   | 154 +++-
 drivers/net/ethernet/mellanox/mlx5/core/debugfs.c |  14 +-
 drivers/net/ethernet/mellanox/mlx5/core/qp.c  | 167 --
 include/linux/mlx5/mlx5_ifc.h |   5 +-
 include/linux/mlx5/qp.h   | 108 +-
 5 files changed, 165 insertions(+), 283 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 21ab0e2..d22492f 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -726,7 +726,7 @@ err_umem:
 static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
  struct mlx5_ib_qp *qp, struct ib_udata *udata,
  struct ib_qp_init_attr *attr,
- struct mlx5_create_qp_mbox_in **in,
+ u32 **in,
  struct mlx5_ib_create_qp_resp *resp, int *inlen,
  struct mlx5_ib_qp_base *base)
 {
@@ -739,6 +739,8 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct 
ib_pd *pd,
u32 offset = 0;
int uuarn;
int ncont = 0;
+   __be64 *pas;
+   void *qpc;
int err;
 
err = ib_copy_from_udata(, udata, sizeof(ucmd));
@@ -795,20 +797,24 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct 
ib_pd *pd,
ubuffer->umem = NULL;
}
 
-   *inlen = sizeof(**in) + sizeof(*(*in)->pas) * ncont;
+   *inlen = MLX5_ST_SZ_BYTES(create_qp_in) +
+MLX5_FLD_SZ_BYTES(create_qp_in, pas[0]) * ncont;
*in = mlx5_vzalloc(*inlen);
if (!*in) {
err = -ENOMEM;
goto err_umem;
}
+
+   pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
if (ubuffer->umem)
-   mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift,
-(*in)->pas, 0);
-   (*in)->ctx.log_pg_sz_remote_qpn =
-   cpu_to_be32((page_shift - MLX5_ADAPTER_PAGE_SHIFT) << 24);
-   (*in)->ctx.params2 = cpu_to_be32(offset << 6);
+   mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0);
+
+   qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
+
+   MLX5_SET(qpc, qpc, log_page_size, page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+   MLX5_SET(qpc, qpc, page_offset, offset);
 
-   (*in)->ctx.qp_counter_set_usr_page = cpu_to_be32(uar_index);
+   MLX5_SET(qpc, qpc, uar_page, uar_index);
resp->uuar_index = uuarn;
qp->uuarn = uuarn;
 
@@ -857,12 +863,13 @@ static void destroy_qp_user(struct ib_pd *pd, struct 
mlx5_ib_qp *qp,
 static int create_kernel_qp(struct mlx5_ib_dev *dev,
struct ib_qp_init_attr *init_attr,
struct mlx5_ib_qp *qp,
-   struct mlx5_create_qp_mbox_in **in, int *inlen,
+   u32 **in, int *inlen,
struct mlx5_ib_qp_base *base)
 {
enum mlx5_ib_latency_class lc = MLX5_IB_LATENCY_CLASS_LOW;
struct mlx5_uuar_info *uuari;
int uar_index;
+   void *qpc;
int uuarn;
int err;
 
@@ -902,25 +909,29 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
}
 
qp->sq.qend = mlx5_get_send_wqe(qp, qp->sq.wqe_cnt);
-   *inlen = sizeof(**in) + sizeof(*(*in)->pas) * qp->buf.npages;
+   *inlen = MLX5_ST_SZ_BYTES(create_qp_in) +
+MLX5_FLD_SZ_BYTES(create_qp_in, pas[0]) * qp->buf.npages;
*in = mlx5_vzalloc(*inlen);
if (!*in) {
err = -ENOMEM;
goto err_buf;
}
-   (*in)->ctx.qp_counter_set_usr_page = cpu_to_be32(uar_index);
-   (*in)->ctx.log_pg_sz_remote_qpn =
-   cpu_to_be32((qp->buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT) << 
24);
+
+   qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
+   MLX5_SET(qpc, qpc, uar_page, uar_index);
+   MLX5_SET(qpc, qpc, log_page_size, qp->buf.page_shift - 
MLX5_ADAPTER_PAGE_SHIFT);
+
/* Set "fast registration enabled" for all kernel QPs */
-   (*in)->ctx.params1 |= cpu_to_be32(1 << 11);
-   (*in)->ctx.sq_crq_size |= cpu_to_be16(1 << 4);
+   MLX5_SET(qpc, qpc, fre, 1);
+   MLX5_SET(qpc, qpc, rlky, 1);
 
if (init_attr->create_flags & mlx5_ib_create_qp_sqpn_qp1()) {
-   (*in)->ctx.deth_sqpn = cpu_to_be32(1);
+   MLX5_SET(qpc, qpc, deth_sqpn, 1);
qp->flags |= MLX5_IB_QP_SQPN_QP1;
}
 
-   mlx5_fill_page_array(>buf, (*in)->pas);
+   mlx5_fill_page_array(>buf,
+(__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas));
 
err = 

[PATCH net-next 08/30] {net,IB}/mlx5: MKey/PSV commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created MKey/PSV commands layout,
and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h   |   2 +-
 drivers/infiniband/hw/mlx5/mr.c| 184 -
 drivers/infiniband/hw/mlx5/qp.c|   8 +-
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c  |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en_common.c|  23 +--
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  37 ++---
 drivers/net/ethernet/mellanox/mlx5/core/mr.c   | 183 +---
 include/linux/mlx5/device.h| 113 +
 include/linux/mlx5/driver.h|  11 +-
 include/linux/mlx5/mlx5_ifc.h  |   2 +-
 10 files changed, 235 insertions(+), 332 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h 
b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 372385d..a59034a 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -504,7 +504,7 @@ struct mlx5_ib_mr {
int umred;
int npages;
struct mlx5_ib_dev *dev;
-   struct mlx5_create_mkey_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(create_mkey_out)];
struct mlx5_core_sig_ctx*sig;
int live;
void*descs_alloc;
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 4b02130..6f7e347 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -135,20 +135,10 @@ static void reg_mr_callback(int status, void *context)
return;
}
 
-   if (mr->out.hdr.status) {
-   mlx5_ib_warn(dev, "failed - status %d, syndorme 0x%x\n",
-mr->out.hdr.status,
-be32_to_cpu(mr->out.hdr.syndrome));
-   kfree(mr);
-   dev->fill_delay = 1;
-   mod_timer(>delay_timer, jiffies + HZ);
-   return;
-   }
-
spin_lock_irqsave(>mdev->priv.mkey_lock, flags);
key = dev->mdev->priv.mkey_key++;
spin_unlock_irqrestore(>mdev->priv.mkey_lock, flags);
-   mr->mmkey.key = mlx5_idx_to_mkey(be32_to_cpu(mr->out.mkey) & 0xff) 
| key;
+   mr->mmkey.key = mlx5_idx_to_mkey(MLX5_GET(create_mkey_out, mr->out, 
mkey_index)) | key;
 
cache->last_add = jiffies;
 
@@ -170,16 +160,19 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int 
num)
 {
struct mlx5_mr_cache *cache = >cache;
struct mlx5_cache_ent *ent = >ent[c];
-   struct mlx5_create_mkey_mbox_in *in;
+   int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
struct mlx5_ib_mr *mr;
int npages = 1 << ent->order;
+   void *mkc;
+   u32 *in;
int err = 0;
int i;
 
-   in = kzalloc(sizeof(*in), GFP_KERNEL);
+   in = kzalloc(inlen, GFP_KERNEL);
if (!in)
return -ENOMEM;
 
+   mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
for (i = 0; i < num; i++) {
if (ent->pending >= MAX_PENDING_REG_MR) {
err = -EAGAIN;
@@ -194,18 +187,22 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int 
num)
mr->order = ent->order;
mr->umred = 1;
mr->dev = dev;
-   in->seg.status = MLX5_MKEY_STATUS_FREE;
-   in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2);
-   in->seg.qpn_mkey7_0 = cpu_to_be32(0xff << 8);
-   in->seg.flags = MLX5_ACCESS_MODE_MTT | MLX5_PERM_UMR_EN;
-   in->seg.log2_page_size = 12;
+
+   MLX5_SET(mkc, mkc, free, 1);
+   MLX5_SET(mkc, mkc, umr_en, 1);
+   MLX5_SET(mkc, mkc, access_mode, MLX5_MKC_ACCESS_MODE_MTT);
+
+   MLX5_SET(mkc, mkc, qpn, 0xff);
+   MLX5_SET(mkc, mkc, translations_octword_size, (npages + 1) / 2);
+   MLX5_SET(mkc, mkc, log_page_size, 12);
 
spin_lock_irq(>lock);
ent->pending++;
spin_unlock_irq(>lock);
-   err = mlx5_core_create_mkey(dev->mdev, >mmkey, in,
-   sizeof(*in), reg_mr_callback,
-   mr, >out);
+   err = mlx5_core_create_mkey_cb(dev->mdev, >mmkey,
+  in, inlen,
+  mr->out, sizeof(mr->out),
+  reg_mr_callback, mr);
if (err) {
spin_lock_irq(>lock);
ent->pending--;
@@ -670,30 +667,38 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
 struct ib_mr 

[PATCH net-next 24/30] net/mlx5: LAG and SRIOV cannot be used together

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

Until support will be added for RoCE LAG SRIOV.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/lag.c   |  6 ++
 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h |  1 +
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 12 
 3 files changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c 
b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
index 9523050..3cb570a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -201,6 +201,12 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)
mutex_unlock(_mutex);
 
if (tracker.is_bonded && !mlx5_lag_is_bonded(ldev)) {
+   if (mlx5_sriov_is_enabled(dev0) ||
+   mlx5_sriov_is_enabled(dev1)) {
+   mlx5_core_warn(dev0, "LAG is not supported with SRIOV");
+   return;
+   }
+
for (i = 0; i < MLX5_MAX_PORTS; i++)
mlx5_remove_dev_by_protocol(ldev->pf[i].dev,
MLX5_INTERFACE_PROTOCOL_IB);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h 
b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index e716996..8557435 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -90,6 +90,7 @@ void mlx5_core_event(struct mlx5_core_dev *dev, enum 
mlx5_dev_event event,
 void mlx5_enter_error_state(struct mlx5_core_dev *dev);
 void mlx5_disable_device(struct mlx5_core_dev *dev);
 int mlx5_core_sriov_configure(struct pci_dev *dev, int num_vfs);
+bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev);
 int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id);
 int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id);
 int mlx5_wait_for_vf_pages(struct mlx5_core_dev *dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c 
b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
index 0680dfb..78e7892 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
@@ -37,6 +37,13 @@
 #include "eswitch.h"
 #endif
 
+bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev)
+{
+   struct mlx5_core_sriov *sriov = >priv.sriov;
+
+   return !!sriov->num_vfs;
+}
+
 static void enable_vfs(struct mlx5_core_dev *dev, int num_vfs)
 {
struct mlx5_core_sriov *sriov = >priv.sriov;
@@ -144,6 +151,11 @@ int mlx5_core_sriov_configure(struct pci_dev *pdev, int 
num_vfs)
if (!mlx5_core_is_pf(dev))
return -EPERM;
 
+   if (num_vfs && mlx5_lag_is_active(dev)) {
+   mlx5_core_warn(dev, "can't turn sriov on while LAG is active");
+   return -EINVAL;
+   }
+
mlx5_core_cleanup_vfs(dev);
 
if (!num_vfs) {
-- 
2.7.4



[PATCH net-next 13/30] net/mlx5: Enable setting minimum inline header mode for VFs

2016-08-20 Thread Saeed Mahameed
From: Hadar Hen Zion 

Implement the low-level part of the PF side in setting minimum
inline header mode for VFs.

Signed-off-by: Hadar Hen Zion 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/vport.c | 20 
 include/linux/mlx5/mlx5_ifc.h   |  2 +-
 include/linux/mlx5/vport.h  |  2 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c 
b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
index 3593bf7..525f17a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
@@ -125,6 +125,26 @@ void mlx5_query_nic_vport_min_inline(struct mlx5_core_dev 
*mdev,
 }
 EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_min_inline);
 
+int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
+u16 vport, u8 min_inline)
+{
+   u32 in[MLX5_ST_SZ_DW(modify_nic_vport_context_in)] = {0};
+   int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
+   void *nic_vport_ctx;
+
+   MLX5_SET(modify_nic_vport_context_in, in,
+field_select.min_inline, 1);
+   MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+   MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
+
+   nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
+in, nic_vport_context);
+   MLX5_SET(nic_vport_context, nic_vport_ctx,
+min_wqe_inline_mode, min_inline);
+
+   return mlx5_modify_nic_vport_context(mdev, in, inlen);
+}
+
 int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
 u16 vport, u8 *addr)
 {
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index cb94ac5..7a8ef0a 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -4724,7 +4724,7 @@ struct mlx5_ifc_modify_nic_vport_field_select_bits {
u8 reserved_at_0[0x16];
u8 node_guid[0x1];
u8 port_guid[0x1];
-   u8 reserved_at_18[0x1];
+   u8 min_inline[0x1];
u8 mtu[0x1];
u8 change_event[0x1];
u8 promisc[0x1];
diff --git a/include/linux/mlx5/vport.h b/include/linux/mlx5/vport.h
index e087b7d..451b0bd 100644
--- a/include/linux/mlx5/vport.h
+++ b/include/linux/mlx5/vport.h
@@ -45,6 +45,8 @@ int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev 
*mdev,
 u16 vport, u8 *addr);
 void mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
 u8 *min_inline);
+int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
+u16 vport, u8 min_inline);
 int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *dev,
  u16 vport, u8 *addr);
 int mlx5_query_nic_vport_mtu(struct mlx5_core_dev *mdev, u16 *mtu);
-- 
2.7.4



[PATCH net-next 11/30] net/mlx5: Unify and improve command interface

2016-08-20 Thread Saeed Mahameed
Now as all commands use mlx5 ifc interface, instead of doing two calls
for executing a command we embed command status checking into
mlx5_cmd_exec to simplify the interface.

Also we do here some cleanup for redundant software structures
(inbox/outbox) and functions and improved command failure output.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/hw/mlx5/main.c  |  10 +-
 drivers/infiniband/hw/mlx5/qp.c|   5 +-
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c  | 251 +++--
 drivers/net/ethernet/mellanox/mlx5/core/cq.c   |  16 +-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   |   3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  10 +-
 drivers/net/ethernet/mellanox/mlx5/core/eq.c   |  12 +-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  |  72 ++
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c   | 130 +++
 drivers/net/ethernet/mellanox/mlx5/core/fw.c   |  15 +-
 drivers/net/ethernet/mellanox/mlx5/core/mad.c  |   1 -
 drivers/net/ethernet/mellanox/mlx5/core/main.c |  80 ++-
 drivers/net/ethernet/mellanox/mlx5/core/mcg.c  |  10 +-
 .../net/ethernet/mellanox/mlx5/core/mlx5_core.h|  13 --
 drivers/net/ethernet/mellanox/mlx5/core/mr.c   |  28 +--
 .../net/ethernet/mellanox/mlx5/core/pagealloc.c|  11 +-
 drivers/net/ethernet/mellanox/mlx5/core/pd.c   |  11 +-
 drivers/net/ethernet/mellanox/mlx5/core/port.c |  99 ++--
 drivers/net/ethernet/mellanox/mlx5/core/qp.c   |  26 +--
 drivers/net/ethernet/mellanox/mlx5/core/rl.c   |  11 +-
 drivers/net/ethernet/mellanox/mlx5/core/srq.c  |  49 ++--
 drivers/net/ethernet/mellanox/mlx5/core/transobj.c | 183 +--
 drivers/net/ethernet/mellanox/mlx5/core/uar.c  |  11 +-
 drivers/net/ethernet/mellanox/mlx5/core/vport.c|  74 ++
 drivers/net/ethernet/mellanox/mlx5/core/vxlan.c|  29 +--
 include/linux/mlx5/device.h| 115 --
 include/linux/mlx5/driver.h|   7 +-
 27 files changed, 385 insertions(+), 897 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c 
b/drivers/infiniband/hw/mlx5/main.c
index a84bb76..6fb77d7 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -233,23 +233,19 @@ static int set_roce_addr(struct ib_device *device, u8 
port_num,
 const union ib_gid *gid,
 const struct ib_gid_attr *attr)
 {
-   struct mlx5_ib_dev *dev = to_mdev(device);
-   u32  in[MLX5_ST_SZ_DW(set_roce_address_in)];
-   u32 out[MLX5_ST_SZ_DW(set_roce_address_out)];
+   struct mlx5_ib_dev *dev = to_mdev(device);
+   u32  in[MLX5_ST_SZ_DW(set_roce_address_in)]  = {0};
+   u32 out[MLX5_ST_SZ_DW(set_roce_address_out)] = {0};
void *in_addr = MLX5_ADDR_OF(set_roce_address_in, in, roce_address);
enum rdma_link_layer ll = mlx5_ib_port_link_layer(device, port_num);
 
if (ll != IB_LINK_LAYER_ETHERNET)
return -EINVAL;
 
-   memset(in, 0, sizeof(in));
-
ib_gid_to_mlx5_roce_addr(gid, attr, in_addr);
 
MLX5_SET(set_roce_address_in, in, roce_address_index, index);
MLX5_SET(set_roce_address_in, in, opcode, MLX5_CMD_OP_SET_ROCE_ADDRESS);
-
-   memset(out, 0, sizeof(out));
return mlx5_cmd_exec(dev->mdev, in, sizeof(in), out, sizeof(out));
 }
 
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 6261737..f3c943f 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1007,13 +1007,10 @@ static int is_connected(enum ib_qp_type qp_type)
 static int create_raw_packet_qp_tis(struct mlx5_ib_dev *dev,
struct mlx5_ib_sq *sq, u32 tdn)
 {
-   u32 in[MLX5_ST_SZ_DW(create_tis_in)];
+   u32 in[MLX5_ST_SZ_DW(create_tis_in)] = {0};
void *tisc = MLX5_ADDR_OF(create_tis_in, in, ctx);
 
-   memset(in, 0, sizeof(in));
-
MLX5_SET(tisc, tisc, transport_domain, tdn);
-
return mlx5_core_create_tis(dev->mdev, in, sizeof(in), >tisn);
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 88b0540..23b95da 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -554,11 +554,124 @@ const char *mlx5_command_str(int command)
}
 }
 
+static const char *cmd_status_str(u8 status)
+{
+   switch (status) {
+   case MLX5_CMD_STAT_OK:
+   return "OK";
+   case MLX5_CMD_STAT_INT_ERR:
+   return "internal error";
+   case MLX5_CMD_STAT_BAD_OP_ERR:
+   return "bad operation";
+   case MLX5_CMD_STAT_BAD_PARAM_ERR:
+   return "bad parameter";
+   case MLX5_CMD_STAT_BAD_SYS_STATE_ERR:
+   return "bad system 

[PATCH net-next 25/30] net/mlx5: LAG demux flow table support

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

Add interfaces to allow the creation and destruction of a
LAG demux flow table.

It is a special flow table used during LAG for redirecting
non user-mode packets from PF0 to PF1 root ft, if a packet was
received on phys port two.

Signed-off-by: Aviv Heller 
Reviewed-by: Maor Gottlieb 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c  | 56 +--
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h  |  1 +
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 31 +
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.h |  6 +++
 include/linux/mlx5/fs.h   |  3 ++
 5 files changed, 75 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index 7aaefa9..7a0415e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -58,6 +58,7 @@ int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
 
 int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev,
   u16 vport,
+  enum fs_flow_table_op_mod op_mod,
   enum fs_flow_table_type type, unsigned int level,
   unsigned int log_size, struct mlx5_flow_table
   *next_ft, unsigned int *table_id)
@@ -69,10 +70,6 @@ int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev,
MLX5_SET(create_flow_table_in, in, opcode,
 MLX5_CMD_OP_CREATE_FLOW_TABLE);
 
-   if (next_ft) {
-   MLX5_SET(create_flow_table_in, in, table_miss_mode, 1);
-   MLX5_SET(create_flow_table_in, in, table_miss_id, next_ft->id);
-   }
MLX5_SET(create_flow_table_in, in, table_type, type);
MLX5_SET(create_flow_table_in, in, level, level);
MLX5_SET(create_flow_table_in, in, log_size, log_size);
@@ -81,6 +78,22 @@ int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev,
MLX5_SET(create_flow_table_in, in, other_vport, 1);
}
 
+   switch (op_mod) {
+   case FS_FT_OP_MOD_NORMAL:
+   if (next_ft) {
+   MLX5_SET(create_flow_table_in, in, table_miss_mode, 1);
+   MLX5_SET(create_flow_table_in, in, table_miss_id, 
next_ft->id);
+   }
+   break;
+
+   case FS_FT_OP_MOD_LAG_DEMUX:
+   MLX5_SET(create_flow_table_in, in, op_mod, 0x1);
+   if (next_ft)
+   MLX5_SET(create_flow_table_in, in, 
lag_master_next_table_id,
+next_ft->id);
+   break;
+   }
+
err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
if (!err)
*table_id = MLX5_GET(create_flow_table_out, out,
@@ -117,17 +130,32 @@ int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev,
 MLX5_CMD_OP_MODIFY_FLOW_TABLE);
MLX5_SET(modify_flow_table_in, in, table_type, ft->type);
MLX5_SET(modify_flow_table_in, in, table_id, ft->id);
-   if (ft->vport) {
-   MLX5_SET(modify_flow_table_in, in, vport_number, ft->vport);
-   MLX5_SET(modify_flow_table_in, in, other_vport, 1);
-   }
-   MLX5_SET(modify_flow_table_in, in, modify_field_select,
-MLX5_MODIFY_FLOW_TABLE_MISS_TABLE_ID);
-   if (next_ft) {
-   MLX5_SET(modify_flow_table_in, in, table_miss_mode, 1);
-   MLX5_SET(modify_flow_table_in, in, table_miss_id, next_ft->id);
+
+   if (ft->op_mod == FS_FT_OP_MOD_LAG_DEMUX) {
+   MLX5_SET(modify_flow_table_in, in, modify_field_select,
+MLX5_MODIFY_FLOW_TABLE_LAG_NEXT_TABLE_ID);
+   if (next_ft) {
+   MLX5_SET(modify_flow_table_in, in,
+lag_master_next_table_id, next_ft->id);
+   } else {
+   MLX5_SET(modify_flow_table_in, in,
+lag_master_next_table_id, 0);
+   }
} else {
-   MLX5_SET(modify_flow_table_in, in, table_miss_mode, 0);
+   if (ft->vport) {
+   MLX5_SET(modify_flow_table_in, in, vport_number,
+ft->vport);
+   MLX5_SET(modify_flow_table_in, in, other_vport, 1);
+   }
+   MLX5_SET(modify_flow_table_in, in, modify_field_select,
+MLX5_MODIFY_FLOW_TABLE_MISS_TABLE_ID);
+   if (next_ft) {
+   MLX5_SET(modify_flow_table_in, in, table_miss_mode, 1);
+   MLX5_SET(modify_flow_table_in, in, table_miss_id,
+next_ft->id);
+  

[PATCH net-next 15/30] net/mlx5: Introduce alloc_encap and dealloc_encap commands

2016-08-20 Thread Saeed Mahameed
From: Ilya Lesokhin 

Implement low-level commands to support vxlan encapsulation.

Signed-off-by: Ilya Lesokhin 
Signed-off-by: Hadar Hen Zion 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c|  4 ++
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 48 
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h |  7 
 3 files changed, 59 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 23b95da..00bec60 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -301,6 +301,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev 
*dev, u16 op,
case MLX5_CMD_OP_MODIFY_FLOW_TABLE:
case MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY:
case MLX5_CMD_OP_SET_FLOW_TABLE_ROOT:
+   case MLX5_CMD_OP_DEALLOC_ENCAP_HEADER:
return MLX5_CMD_STAT_OK;
 
case MLX5_CMD_OP_QUERY_HCA_CAP:
@@ -402,6 +403,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev 
*dev, u16 op,
case MLX5_CMD_OP_QUERY_FLOW_TABLE_ENTRY:
case MLX5_CMD_OP_ALLOC_FLOW_COUNTER:
case MLX5_CMD_OP_QUERY_FLOW_COUNTER:
+   case MLX5_CMD_OP_ALLOC_ENCAP_HEADER:
*status = MLX5_DRIVER_STATUS_ABORTED;
*synd = MLX5_DRIVER_SYND;
return -EIO;
@@ -550,6 +552,8 @@ const char *mlx5_command_str(int command)
MLX5_COMMAND_STR_CASE(DEALLOC_FLOW_COUNTER);
MLX5_COMMAND_STR_CASE(QUERY_FLOW_COUNTER);
MLX5_COMMAND_STR_CASE(MODIFY_FLOW_TABLE);
+   MLX5_COMMAND_STR_CASE(ALLOC_ENCAP_HEADER);
+   MLX5_COMMAND_STR_CASE(DEALLOC_ENCAP_HEADER);
default: return "unknown command opcode";
}
 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index e64499e..7aaefa9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -424,3 +424,51 @@ void mlx5_cmd_fc_bulk_get(struct mlx5_core_dev *dev,
*packets = MLX5_GET64(traffic_counter, stats, packets);
*bytes = MLX5_GET64(traffic_counter, stats, octets);
 }
+
+#define MAX_ENCAP_SIZE (128)
+
+int mlx5_cmd_alloc_encap(struct mlx5_core_dev *dev,
+int header_type,
+size_t size,
+void *encap_header,
+u32 *encap_id)
+{
+   u32 out[MLX5_ST_SZ_DW(alloc_encap_header_out)];
+   u32 in[MLX5_ST_SZ_DW(alloc_encap_header_in) +
+ (MAX_ENCAP_SIZE / sizeof(u32))];
+   void *encap_header_in = MLX5_ADDR_OF(alloc_encap_header_in, in,
+encap_header);
+   void *header = MLX5_ADDR_OF(encap_header_in, encap_header_in,
+   encap_header);
+   int inlen = header - (void *)in  + size;
+   int err;
+
+   if (size > MAX_ENCAP_SIZE)
+   return -EINVAL;
+
+   memset(in, 0, inlen);
+   MLX5_SET(alloc_encap_header_in, in, opcode,
+MLX5_CMD_OP_ALLOC_ENCAP_HEADER);
+   MLX5_SET(encap_header_in, encap_header_in, encap_header_size, size);
+   MLX5_SET(encap_header_in, encap_header_in, header_type, header_type);
+   memcpy(header, encap_header, size);
+
+   memset(out, 0, sizeof(out));
+   err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
+
+   *encap_id = MLX5_GET(alloc_encap_header_out, out, encap_id);
+   return err;
+}
+
+void mlx5_cmd_dealloc_encap(struct mlx5_core_dev *dev, u32 encap_id)
+{
+   u32 in[MLX5_ST_SZ_DW(dealloc_encap_header_in)];
+   u32 out[MLX5_ST_SZ_DW(dealloc_encap_header_out)];
+
+   memset(in, 0, sizeof(in));
+   MLX5_SET(dealloc_encap_header_in, in, opcode,
+MLX5_CMD_OP_DEALLOC_ENCAP_HEADER);
+   MLX5_SET(dealloc_encap_header_in, in, encap_id, encap_id);
+
+   mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
index 158844c..ac52fdf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
@@ -88,4 +88,11 @@ void mlx5_cmd_fc_bulk_get(struct mlx5_core_dev *dev,
  struct mlx5_cmd_fc_bulk *b, u16 id,
  u64 *packets, u64 *bytes);
 
+int mlx5_cmd_alloc_encap(struct mlx5_core_dev *dev,
+int header_type,
+size_t size,
+void *encap_header,
+u32 *encap_id);
+void mlx5_cmd_dealloc_encap(struct mlx5_core_dev *dev, u32 encap_id);
+
 #endif
-- 
2.7.4



[PATCH net-next 16/30] net/mlx5: Modify RQ bitmask from mlx5 ifc

2016-08-20 Thread Saeed Mahameed
From: Alex Vesker 

Use mlx5 ifc MODIFY_BITMASK_VSD in mlx5e_modify_rq_vsd and expose counter
set capability bit in hca caps structure.

Signed-off-by: Alex Vesker 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 ++-
 include/linux/mlx5/driver.h   | 4 
 include/linux/mlx5/mlx5_ifc.h | 9 -
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 10fa12a..9e36c15 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -489,7 +489,8 @@ static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool 
vsd)
rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
 
MLX5_SET(modify_rq_in, in, rq_state, MLX5_RQC_STATE_RDY);
-   MLX5_SET64(modify_rq_in, in, modify_bitmask, MLX5_RQ_BITMASK_VSD);
+   MLX5_SET64(modify_rq_in, in, modify_bitmask,
+  MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD);
MLX5_SET(rqc, rqc, vsd, vsd);
MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RDY);
 
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index ebe57ab..0ea78b5 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -49,10 +49,6 @@
 #include 
 
 enum {
-   MLX5_RQ_BITMASK_VSD = 1 << 1,
-};
-
-enum {
MLX5_BOARD_ID_LEN = 64,
MLX5_MAX_NAME_LEN = 16,
 };
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 3766110..e1f8e34 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -779,7 +779,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
u8 out_of_seq_cnt[0x1];
u8 vport_counters[0x1];
u8 retransmission_q_counters[0x1];
-   u8 reserved_at_183[0x3];
+   u8 reserved_at_183[0x1];
+   u8 modify_rq_counter_set_id[0x1];
+   u8 reserved_at_185[0x1];
u8 max_qp_cnt[0xa];
u8 pkey_table_size[0x10];
 
@@ -4750,6 +4752,11 @@ struct mlx5_ifc_modify_rq_out_bits {
u8 reserved_at_40[0x40];
 };
 
+enum {
+   MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD = 1ULL << 1,
+   MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_MODIFY_RQ_COUNTER_SET_ID = 1ULL << 3,
+};
+
 struct mlx5_ifc_modify_rq_in_bits {
u8 opcode[0x10];
u8 reserved_at_10[0x10];
-- 
2.7.4



[PATCH net-next 30/30] net/mlx5: Add sniffer namespaces

2016-08-20 Thread Saeed Mahameed
From: Maor Gottlieb 

Add sniffer TX and RX namespaces to receive ingoing and outgoing
traffic.

Each outgoing/incoming packet is duplicated and steered to the sniffer
TX/RX namespace in addition to the regular flow.

Signed-off-by: Maor Gottlieb 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 58 +++
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.h |  4 ++
 include/linux/mlx5/fs.h   |  2 +
 3 files changed, 64 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index ac414b7..f5571a5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1427,6 +1427,16 @@ struct mlx5_flow_namespace 
*mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
return >esw_ingress_root_ns->ns;
else
return NULL;
+   case MLX5_FLOW_NAMESPACE_SNIFFER_RX:
+   if (steering->sniffer_rx_root_ns)
+   return >sniffer_rx_root_ns->ns;
+   else
+   return NULL;
+   case MLX5_FLOW_NAMESPACE_SNIFFER_TX:
+   if (steering->sniffer_tx_root_ns)
+   return >sniffer_tx_root_ns->ns;
+   else
+   return NULL;
default:
return NULL;
}
@@ -1726,10 +1736,46 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
cleanup_root_ns(steering->esw_egress_root_ns);
cleanup_root_ns(steering->esw_ingress_root_ns);
cleanup_root_ns(steering->fdb_root_ns);
+   cleanup_root_ns(steering->sniffer_rx_root_ns);
+   cleanup_root_ns(steering->sniffer_tx_root_ns);
mlx5_cleanup_fc_stats(dev);
kfree(steering);
 }
 
+static int init_sniffer_tx_root_ns(struct mlx5_flow_steering *steering)
+{
+   struct fs_prio *prio;
+
+   steering->sniffer_tx_root_ns = create_root_ns(steering, 
FS_FT_SNIFFER_TX);
+   if (!steering->sniffer_tx_root_ns)
+   return -ENOMEM;
+
+   /* Create single prio */
+   prio = fs_create_prio(>sniffer_tx_root_ns->ns, 0, 1);
+   if (IS_ERR(prio)) {
+   cleanup_root_ns(steering->sniffer_tx_root_ns);
+   return PTR_ERR(prio);
+   }
+   return 0;
+}
+
+static int init_sniffer_rx_root_ns(struct mlx5_flow_steering *steering)
+{
+   struct fs_prio *prio;
+
+   steering->sniffer_rx_root_ns = create_root_ns(steering, 
FS_FT_SNIFFER_RX);
+   if (!steering->sniffer_rx_root_ns)
+   return -ENOMEM;
+
+   /* Create single prio */
+   prio = fs_create_prio(>sniffer_rx_root_ns->ns, 0, 1);
+   if (IS_ERR(prio)) {
+   cleanup_root_ns(steering->sniffer_rx_root_ns);
+   return PTR_ERR(prio);
+   }
+   return 0;
+}
+
 static int init_fdb_root_ns(struct mlx5_flow_steering *steering)
 {
struct fs_prio *prio;
@@ -1826,6 +1872,18 @@ int mlx5_init_fs(struct mlx5_core_dev *dev)
}
}
 
+   if (MLX5_CAP_FLOWTABLE_SNIFFER_RX(dev, ft_support)) {
+   err = init_sniffer_rx_root_ns(steering);
+   if (err)
+   goto err;
+   }
+
+   if (MLX5_CAP_FLOWTABLE_SNIFFER_TX(dev, ft_support)) {
+   err = init_sniffer_tx_root_ns(steering);
+   if (err)
+   goto err;
+   }
+
return 0;
 err:
mlx5_cleanup_fs(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
index 23e46e3..71ff03b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
@@ -49,6 +49,8 @@ enum fs_flow_table_type {
FS_FT_ESW_EGRESS_ACL  = 0x2,
FS_FT_ESW_INGRESS_ACL = 0x3,
FS_FT_FDB = 0X4,
+   FS_FT_SNIFFER_RX= 0X5,
+   FS_FT_SNIFFER_TX= 0X6,
 };
 
 enum fs_flow_table_op_mod {
@@ -66,6 +68,8 @@ struct mlx5_flow_steering {
struct mlx5_flow_root_namespace *fdb_root_ns;
struct mlx5_flow_root_namespace *esw_egress_root_ns;
struct mlx5_flow_root_namespace *esw_ingress_root_ns;
+   struct mlx5_flow_root_namespace *sniffer_tx_root_ns;
+   struct mlx5_flow_root_namespace *sniffer_rx_root_ns;
 };
 
 struct fs_node {
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
index 8803212..93ebc5e 100644
--- a/include/linux/mlx5/fs.h
+++ b/include/linux/mlx5/fs.h
@@ -63,6 +63,8 @@ enum mlx5_flow_namespace_type {
MLX5_FLOW_NAMESPACE_FDB,
MLX5_FLOW_NAMESPACE_ESW_EGRESS,
MLX5_FLOW_NAMESPACE_ESW_INGRESS,
+   MLX5_FLOW_NAMESPACE_SNIFFER_RX,
+   MLX5_FLOW_NAMESPACE_SNIFFER_TX,
 };
 
 struct mlx5_flow_table;
-- 
2.7.4


[PATCH net-next 04/30] net/mlx5: MCG commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created MCG commands layout
and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c |  4 +-
 drivers/net/ethernet/mellanox/mlx5/core/mcg.c | 70 +++
 include/linux/mlx5/mlx5_ifc.h |  2 +-
 3 files changed, 21 insertions(+), 55 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index d6e2a1c..0d55e0f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -280,7 +280,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev 
*dev, u16 op,
case MLX5_CMD_OP_DEALLOC_Q_COUNTER:
case MLX5_CMD_OP_DEALLOC_PD:
case MLX5_CMD_OP_DEALLOC_UAR:
-   case MLX5_CMD_OP_DETTACH_FROM_MCG:
+   case MLX5_CMD_OP_DETACH_FROM_MCG:
case MLX5_CMD_OP_DEALLOC_XRCD:
case MLX5_CMD_OP_DEALLOC_TRANSPORT_DOMAIN:
case MLX5_CMD_OP_DELETE_VXLAN_UDP_DPORT:
@@ -490,7 +490,7 @@ const char *mlx5_command_str(int command)
MLX5_COMMAND_STR_CASE(CONFIG_INT_MODERATION);
MLX5_COMMAND_STR_CASE(ACCESS_REG);
MLX5_COMMAND_STR_CASE(ATTACH_TO_MCG);
-   MLX5_COMMAND_STR_CASE(DETTACH_FROM_MCG);
+   MLX5_COMMAND_STR_CASE(DETACH_FROM_MCG);
MLX5_COMMAND_STR_CASE(GET_DROPPED_PACKET_LOG);
MLX5_COMMAND_STR_CASE(MAD_IFC);
MLX5_COMMAND_STR_CASE(QUERY_MAD_DEMUX);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mcg.c 
b/drivers/net/ethernet/mellanox/mlx5/core/mcg.c
index d5a0c2d..01a1abd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mcg.c
@@ -37,70 +37,36 @@
 #include 
 #include "mlx5_core.h"
 
-struct mlx5_attach_mcg_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   __be32  qpn;
-   __be32  rsvd;
-   u8  gid[16];
-};
-
-struct mlx5_attach_mcg_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   u8  rsvf[8];
-};
-
-struct mlx5_detach_mcg_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   __be32  qpn;
-   __be32  rsvd;
-   u8  gid[16];
-};
-
-struct mlx5_detach_mcg_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   u8  rsvf[8];
-};
-
 int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 
qpn)
 {
-   struct mlx5_attach_mcg_mbox_in in;
-   struct mlx5_attach_mcg_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(attach_to_mcg_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(attach_to_mcg_in)]   = {0};
+   void *gid;
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ATTACH_TO_MCG);
-   memcpy(in.gid, mgid, sizeof(*mgid));
-   in.qpn = cpu_to_be32(qpn);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
-   if (err)
-   return err;
-
-   if (out.hdr.status)
-   err = mlx5_cmd_status_to_err();
+   MLX5_SET(attach_to_mcg_in, in, opcode, MLX5_CMD_OP_ATTACH_TO_MCG);
+   MLX5_SET(attach_to_mcg_in, in, qpn, qpn);
+   gid = MLX5_ADDR_OF(attach_to_mcg_in, in, multicast_gid);
+   memcpy(gid, mgid, sizeof(*mgid));
 
-   return err;
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   return err ? : mlx5_cmd_status_to_err_v2(out);
 }
 EXPORT_SYMBOL(mlx5_core_attach_mcg);
 
 int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 
qpn)
 {
-   struct mlx5_detach_mcg_mbox_in in;
-   struct mlx5_detach_mcg_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(detach_from_mcg_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(detach_from_mcg_in)]   = {0};
+   void *gid;
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DETTACH_FROM_MCG);
-   memcpy(in.gid, mgid, sizeof(*mgid));
-   in.qpn = cpu_to_be32(qpn);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
-   if (err)
-   return err;
-
-   if (out.hdr.status)
-   err = mlx5_cmd_status_to_err();
+   MLX5_SET(detach_from_mcg_in, in, opcode, MLX5_CMD_OP_DETACH_FROM_MCG);
+   MLX5_SET(detach_from_mcg_in, in, qpn, qpn);
+   gid = MLX5_ADDR_OF(detach_from_mcg_in, in, multicast_gid);
+   memcpy(gid, mgid, sizeof(*mgid));
 
-   return err;
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   return err ? : mlx5_cmd_status_to_err_v2(out);
 }
 EXPORT_SYMBOL(mlx5_core_detach_mcg);
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 21bc455..3f70fc9 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ 

[PATCH net-next 26/30] net/mlx5: Add LAG flow steering namespace

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

This namespace is used for LAG demux flowtable.

The idea is to position the LAG demux ft between
bypass and kernel flowtables, allowing raw-eth
traffic from both ports to be received by the PF0
IB device.

Signed-off-by: Aviv Heller 
Reviewed-by: Maor Gottlieb 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 11 ++-
 include/linux/mlx5/fs.h   |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index eabd734..ac414b7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -96,6 +96,10 @@
 #define OFFLOADS_NUM_PRIOS 1
 #define OFFLOADS_MIN_LEVEL (ANCHOR_MIN_LEVEL + 1)
 
+#define LAG_PRIO_NUM_LEVELS 1
+#define LAG_NUM_PRIOS 1
+#define LAG_MIN_LEVEL (OFFLOADS_MIN_LEVEL + 1)
+
 struct node_caps {
size_t  arr_sz;
long*caps;
@@ -111,12 +115,16 @@ static struct init_tree_node {
int num_levels;
 } root_fs = {
.type = FS_TYPE_NAMESPACE,
-   .ar_size = 6,
+   .ar_size = 7,
.children = (struct init_tree_node[]) {
ADD_PRIO(0, BY_PASS_MIN_LEVEL, 0,
 FS_CHAINING_CAPS,
 ADD_NS(ADD_MULTIPLE_PRIO(MLX5_BY_PASS_NUM_PRIOS,
  BY_PASS_PRIO_NUM_LEVELS))),
+   ADD_PRIO(0, LAG_MIN_LEVEL, 0,
+FS_CHAINING_CAPS,
+ADD_NS(ADD_MULTIPLE_PRIO(LAG_NUM_PRIOS,
+ LAG_PRIO_NUM_LEVELS))),
ADD_PRIO(0, OFFLOADS_MIN_LEVEL, 0, {},
 ADD_NS(ADD_MULTIPLE_PRIO(OFFLOADS_NUM_PRIOS, 
OFFLOADS_MAX_FT))),
ADD_PRIO(0, ETHTOOL_MIN_LEVEL, 0,
@@ -1396,6 +1404,7 @@ struct mlx5_flow_namespace 
*mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
 
switch (type) {
case MLX5_FLOW_NAMESPACE_BYPASS:
+   case MLX5_FLOW_NAMESPACE_LAG:
case MLX5_FLOW_NAMESPACE_OFFLOADS:
case MLX5_FLOW_NAMESPACE_ETHTOOL:
case MLX5_FLOW_NAMESPACE_KERNEL:
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
index 7edfe0b..8803212 100644
--- a/include/linux/mlx5/fs.h
+++ b/include/linux/mlx5/fs.h
@@ -54,6 +54,7 @@ static inline void build_leftovers_ft_param(int *priority,
 
 enum mlx5_flow_namespace_type {
MLX5_FLOW_NAMESPACE_BYPASS,
+   MLX5_FLOW_NAMESPACE_LAG,
MLX5_FLOW_NAMESPACE_OFFLOADS,
MLX5_FLOW_NAMESPACE_ETHTOOL,
MLX5_FLOW_NAMESPACE_KERNEL,
-- 
2.7.4



[PATCH net-next 17/30] net/mlx5: Update struct mlx5_ifc_xrqc_bits

2016-08-20 Thread Saeed Mahameed
From: Artemy Kovalyov 

Update struct mlx5_ifc_xrqc_bits according to last specification

Signed-off-by: Artemy Kovalyov 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 include/linux/mlx5/mlx5_ifc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index e1f8e34..5f150c8 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -2829,7 +2829,7 @@ struct mlx5_ifc_xrqc_bits {
 
struct mlx5_ifc_tag_matching_topology_context_bits 
tag_matching_topology_context;
 
-   u8 reserved_at_180[0x180];
+   u8 reserved_at_180[0x200];
 
struct mlx5_ifc_wq_bits wq;
 };
-- 
2.7.4



[PATCH net-next 21/30] net/mlx5: Implement RoCE LAG feature

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

Available on dual port cards only, this feature keeps
track, using netdev LAG events, of the bonding
and link status of each port's PF netdev.

When both of the card's PF netdevs are enslaved to the
same bond/team master, and only them, LAG state
is active.

During LAG, only one IB device is present for both ports.

In addition to the above, this commit includes FW commands
used for managing the LAG, new facilities for adding and removing
a single device by interface, and port remap functionality according to
bond events.

Please note that this feature is currently used only for mimicking
Ethernet bonding for RoCE - netdevs functionality is not altered,
and their bonding continues to be managed solely by bond/team driver.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/Makefile   |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |   3 +
 drivers/net/ethernet/mellanox/mlx5/core/lag.c  | 530 +
 drivers/net/ethernet/mellanox/mlx5/core/main.c |  51 +-
 .../net/ethernet/mellanox/mlx5/core/mlx5_core.h|  12 +
 include/linux/mlx5/driver.h|   4 +
 6 files changed, 588 insertions(+), 14 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lag.c

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile 
b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index 05cc1ef..dad326c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_MLX5_CORE) += mlx5_core.o
 mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
health.o mcg.o cq.o srq.o alloc.o qp.o port.o mr.o pd.o \
mad.o transobj.o vport.o sriov.o fs_cmd.o fs_core.o \
-   fs_counters.o rl.o
+   fs_counters.o rl.o lag.o
 
 mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o eswitch_offloads.o \
en_main.o en_common.o en_fs.o en_ethtool.o en_tx.o \
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 9e36c15..219804f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3369,6 +3369,8 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
struct mlx5_eswitch *esw = mdev->priv.eswitch;
struct mlx5_eswitch_rep rep;
 
+   mlx5_lag_add(mdev, netdev);
+
if (mlx5e_vxlan_allowed(mdev)) {
rtnl_lock();
udp_tunnel_get_rx_info(netdev);
@@ -3391,6 +3393,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
 {
queue_work(priv->wq, >set_rx_mode_work);
mlx5e_disable_async_events(priv);
+   mlx5_lag_remove(priv->mdev);
 }
 
 static const struct mlx5e_profile mlx5e_nic_profile = {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c 
b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
new file mode 100644
index 000..3bf0a7f
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -0,0 +1,530 @@
+/*
+ * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include "mlx5_core.h"
+
+enum {
+   MLX5_LAG_FLAG_BONDED = 1 << 0,
+};
+
+struct lag_func {
+   struct mlx5_core_dev *dev;
+   struct net_device*netdev;
+};
+
+/* Used for collection of netdev event info. */

[PATCH net-next 23/30] net/mlx5e: Avoid port remapping of mlx5e netdev TISes

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

TISes belonging to the mlx5e NIC should not be
subject to port remap.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c   |  4 
 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 12 
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 219804f..fa40414 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2025,6 +2025,10 @@ static int mlx5e_create_tis(struct mlx5e_priv *priv, int 
tc)
 
MLX5_SET(tisc, tisc, prio, tc << 1);
MLX5_SET(tisc, tisc, transport_domain, mdev->mlx5e_res.td.tdn);
+
+   if (mlx5_lag_is_lacp_owner(mdev))
+   MLX5_SET(tisc, tisc, strict_lag_tx_port_affinity, 1);
+
return mlx5_core_create_tis(mdev, in, sizeof(in), >tisn[tc]);
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h 
b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 173a6b2..e716996 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -107,4 +107,16 @@ void mlx5_remove_dev_by_protocol(struct mlx5_core_dev 
*dev, int protocol);
 void mlx5e_init(void);
 void mlx5e_cleanup(void);
 
+static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev)
+{
+   /* LACP owner conditions:
+* 1) Function is physical.
+* 2) LAG is supported by FW.
+* 3) LAG is managed by driver (currently the only option).
+*/
+   return  MLX5_CAP_GEN(dev, vport_group_manager) &&
+  (MLX5_CAP_GEN(dev, num_lag_ports) > 1) &&
+   MLX5_CAP_GEN(dev, lag_master);
+}
+
 #endif /* __MLX5_CORE_H__ */
-- 
2.7.4



[PATCH net-next 28/30] net/mlx5: Configure IB devices according to LAG state

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

When mlx5_ib is loaded, we would like each card's IB devices
to be added according to its LAG state (one IB device, instead of
two, is to be added if LAG is active).

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/lag.c   | 17 +
 drivers/net/ethernet/mellanox/mlx5/core/main.c  |  3 +++
 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c 
b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
index 5fe320c..92c3e0d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -583,3 +583,20 @@ unlock:
 }
 EXPORT_SYMBOL(mlx5_lag_get_roce_netdev);
 
+bool mlx5_lag_intf_add(struct mlx5_interface *intf, struct mlx5_priv *priv)
+{
+   struct mlx5_core_dev *dev = container_of(priv, struct mlx5_core_dev,
+priv);
+   struct mlx5_lag *ldev;
+
+   if (intf->protocol != MLX5_INTERFACE_PROTOCOL_IB)
+   return true;
+
+   ldev = mlx5_lag_dev_get(dev);
+   if (!ldev || !mlx5_lag_is_bonded(ldev) || ldev->pf[0].dev == dev)
+   return true;
+
+   /* If bonded, we do not add an IB device for PF1. */
+   return false;
+}
+
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index db7bcfc..28e3ce6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -783,6 +783,9 @@ static void mlx5_add_device(struct mlx5_interface *intf, 
struct mlx5_priv *priv)
struct mlx5_device_context *dev_ctx;
struct mlx5_core_dev *dev = container_of(priv, struct mlx5_core_dev, 
priv);
 
+   if (!mlx5_lag_intf_add(intf, priv))
+   return;
+
dev_ctx = kmalloc(sizeof(*dev_ctx), GFP_KERNEL);
if (!dev_ctx)
return;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h 
b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 8557435..714b71b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -105,6 +105,8 @@ void mlx5_lag_remove(struct mlx5_core_dev *dev);
 void mlx5_add_dev_by_protocol(struct mlx5_core_dev *dev, int protocol);
 void mlx5_remove_dev_by_protocol(struct mlx5_core_dev *dev, int protocol);
 
+bool mlx5_lag_intf_add(struct mlx5_interface *intf, struct mlx5_priv *priv);
+
 void mlx5e_init(void);
 void mlx5e_cleanup(void);
 
-- 
2.7.4



[PATCH net-next 19/30] net/mlx5: Separate query_port_proto_oper for IB and EN

2016-08-20 Thread Saeed Mahameed
From: Noa Osherovich 

Replaced mlx5_query_port_proto_oper with separate functions per link
type. The functions should take different arguments so no point in
trying to unite them.

Signed-off-by: Noa Osherovich 
Signed-off-by: Eran Ben Elisha 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/hw/mlx5/main.c  |  3 +--
 drivers/net/ethernet/mellanox/mlx5/core/port.c | 32 ++
 include/linux/mlx5/port.h  |  7 +++---
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c 
b/drivers/infiniband/hw/mlx5/main.c
index 6fb77d7..f02a975 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -748,8 +748,7 @@ static int mlx5_query_hca_port(struct ib_device *ibdev, u8 
port,
 >active_width);
if (err)
goto out;
-   err = mlx5_query_port_proto_oper(mdev, >active_speed, 
MLX5_PTYS_IB,
-port);
+   err = mlx5_query_port_ib_proto_oper(mdev, >active_speed, port);
if (err)
goto out;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c 
b/drivers/net/ethernet/mellanox/mlx5/core/port.c
index 2ee28ad..34e7184 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
@@ -175,25 +175,39 @@ int mlx5_query_port_link_width_oper(struct mlx5_core_dev 
*dev,
 }
 EXPORT_SYMBOL_GPL(mlx5_query_port_link_width_oper);
 
-int mlx5_query_port_proto_oper(struct mlx5_core_dev *dev,
-  u8 *proto_oper, int proto_mask,
-  u8 local_port)
+int mlx5_query_port_eth_proto_oper(struct mlx5_core_dev *dev,
+  u32 *proto_oper, u8 local_port)
 {
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
int err;
 
-   err = mlx5_query_port_ptys(dev, out, sizeof(out), proto_mask, 
local_port);
+   err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN,
+  local_port);
if (err)
return err;
 
-   if (proto_mask == MLX5_PTYS_EN)
-   *proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
-   else
-   *proto_oper = MLX5_GET(ptys_reg, out, ib_proto_oper);
+   *proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
+
+   return 0;
+}
+EXPORT_SYMBOL(mlx5_query_port_eth_proto_oper);
+
+int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,
+ u8 *proto_oper, u8 local_port)
+{
+   u32 out[MLX5_ST_SZ_DW(ptys_reg)];
+   int err;
+
+   err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_IB,
+  local_port);
+   if (err)
+   return err;
+
+   *proto_oper = MLX5_GET(ptys_reg, out, ib_proto_oper);
 
return 0;
 }
-EXPORT_SYMBOL_GPL(mlx5_query_port_proto_oper);
+EXPORT_SYMBOL(mlx5_query_port_ib_proto_oper);
 
 int mlx5_set_port_ptys(struct mlx5_core_dev *dev, bool an_disable,
   u32 proto_admin, int proto_mask)
diff --git a/include/linux/mlx5/port.h b/include/linux/mlx5/port.h
index 6f876a4..b3065ac 100644
--- a/include/linux/mlx5/port.h
+++ b/include/linux/mlx5/port.h
@@ -103,9 +103,10 @@ int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
u32 *proto_admin, int proto_mask);
 int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev,
u8 *link_width_oper, u8 local_port);
-int mlx5_query_port_proto_oper(struct mlx5_core_dev *dev,
-  u8 *proto_oper, int proto_mask,
-  u8 local_port);
+int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,
+ u8 *proto_oper, u8 local_port);
+int mlx5_query_port_eth_proto_oper(struct mlx5_core_dev *dev,
+  u32 *proto_oper, u8 local_port);
 int mlx5_set_port_ptys(struct mlx5_core_dev *dev, bool an_disable,
   u32 proto_admin, int proto_mask);
 void mlx5_toggle_port_link(struct mlx5_core_dev *dev);
-- 
2.7.4



[PATCH net-next 29/30] net/mlx5: Introduce sniffer steering hardware capabilities

2016-08-20 Thread Saeed Mahameed
From: Maor Gottlieb 

Define needed hardware capabilities for sniffer
RX and TX flow tables.

Add the following capabilities:
1. Sniffer RX flow table capabilities.
2. Sniffer TX flow table capabilities.
3. If same TIR can be used by multiple flow tables of different types.

Signed-off-by: Maor Gottlieb 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 include/linux/mlx5/device.h   | 12 
 include/linux/mlx5/mlx5_ifc.h |  4 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 2575070..77c1417 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -964,6 +964,18 @@ enum mlx5_cap_type {
 #define MLX5_CAP_FLOWTABLE_NIC_RX_MAX(mdev, cap) \
MLX5_CAP_FLOWTABLE_MAX(mdev, flow_table_properties_nic_receive.cap)
 
+#define MLX5_CAP_FLOWTABLE_SNIFFER_RX(mdev, cap) \
+   MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_receive_sniffer.cap)
+
+#define MLX5_CAP_FLOWTABLE_SNIFFER_RX_MAX(mdev, cap) \
+   MLX5_CAP_FLOWTABLE_MAX(mdev, 
flow_table_properties_nic_receive_sniffer.cap)
+
+#define MLX5_CAP_FLOWTABLE_SNIFFER_TX(mdev, cap) \
+   MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_transmit_sniffer.cap)
+
+#define MLX5_CAP_FLOWTABLE_SNIFFER_TX_MAX(mdev, cap) \
+   MLX5_CAP_FLOWTABLE_MAX(mdev, 
flow_table_properties_nic_transmit_sniffer.cap)
+
 #define MLX5_CAP_ESW_FLOWTABLE(mdev, cap) \
MLX5_GET(flow_table_eswitch_cap, \
 mdev->hca_caps_cur[MLX5_CAP_ESWITCH_FLOW_TABLE], cap)
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 043d525..73a720f 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -483,7 +483,9 @@ struct mlx5_ifc_ads_bits {
 
 struct mlx5_ifc_flow_table_nic_cap_bits {
u8 nic_rx_multi_path_tirs[0x1];
-   u8 reserved_at_1[0x1ff];
+   u8 nic_rx_multi_path_tirs_fts[0x1];
+   u8 allow_sniffer_and_nic_rx_shared_tir[0x1];
+   u8 reserved_at_3[0x1fd];
 
struct mlx5_ifc_flow_table_prop_layout_bits 
flow_table_properties_nic_receive;
 
-- 
2.7.4



[PATCH net-next 20/30] net/mlx5: Add HW interfaces used by LAG

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

Exposed LAG commands enum and layouts:
- CREATE_LAG
  HW enters LAG mode:
  RoCE traffic from port two is received on PF0 core dev.
  Allows to set tx_affinity (tx port) for QPs and TISes.
  Allows to port remap QPs and TISes, overriding their
  tx_affinity behavior.

- MODIFY_LAG
  Remap QPs and TISes to another port.

- QUERY_LAG
  Query whether LAG mode is active.

- DESTROY_LAG
  HW exits LAG mode, returning to non-LAG behavior.

- CREATE_VPORT_LAG
  Merge Ethernet flow steering, such that traffic received on port
  two jumps to PF0 root flow table.

  Available only in LAG mode.

- DESTROY_VPORT_LAG
  Ethernet flow steering returns to non-LAG behavior.

Caps added:
- lag_master
  Driver is in charge of managing the LAG.
  This is currently the only option.

- num_lag_ports
  LAG is supported only if this field's value is 2.

Other fields:
- QP/TIS tx port affinity
  During LAG, this field controls on which port a QP or TIS resides.

- TIS strict tx affinity
  When this field is set, the TIS will not be subject to port remap by
  CREATE_LAG/MODIFY_LAG.

- LAG demux flow table
  Flow table used for redirecting non user-space traffic back to
  PF1 root flow table, if the packet was received on port two.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c |  12 ++
 include/linux/mlx5/mlx5_ifc.h | 166 --
 2 files changed, 171 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 00bec60..6388bc0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -285,6 +285,8 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev 
*dev, u16 op,
case MLX5_CMD_OP_DEALLOC_TRANSPORT_DOMAIN:
case MLX5_CMD_OP_DELETE_VXLAN_UDP_DPORT:
case MLX5_CMD_OP_DELETE_L2_TABLE_ENTRY:
+   case MLX5_CMD_OP_DESTROY_LAG:
+   case MLX5_CMD_OP_DESTROY_VPORT_LAG:
case MLX5_CMD_OP_DESTROY_TIR:
case MLX5_CMD_OP_DESTROY_SQ:
case MLX5_CMD_OP_DESTROY_RQ:
@@ -376,6 +378,10 @@ static int mlx5_internal_err_ret_value(struct 
mlx5_core_dev *dev, u16 op,
case MLX5_CMD_OP_ADD_VXLAN_UDP_DPORT:
case MLX5_CMD_OP_SET_L2_TABLE_ENTRY:
case MLX5_CMD_OP_QUERY_L2_TABLE_ENTRY:
+   case MLX5_CMD_OP_CREATE_LAG:
+   case MLX5_CMD_OP_MODIFY_LAG:
+   case MLX5_CMD_OP_QUERY_LAG:
+   case MLX5_CMD_OP_CREATE_VPORT_LAG:
case MLX5_CMD_OP_CREATE_TIR:
case MLX5_CMD_OP_MODIFY_TIR:
case MLX5_CMD_OP_QUERY_TIR:
@@ -514,6 +520,12 @@ const char *mlx5_command_str(int command)
MLX5_COMMAND_STR_CASE(DELETE_L2_TABLE_ENTRY);
MLX5_COMMAND_STR_CASE(SET_WOL_ROL);
MLX5_COMMAND_STR_CASE(QUERY_WOL_ROL);
+   MLX5_COMMAND_STR_CASE(CREATE_LAG);
+   MLX5_COMMAND_STR_CASE(MODIFY_LAG);
+   MLX5_COMMAND_STR_CASE(QUERY_LAG);
+   MLX5_COMMAND_STR_CASE(DESTROY_LAG);
+   MLX5_COMMAND_STR_CASE(CREATE_VPORT_LAG);
+   MLX5_COMMAND_STR_CASE(DESTROY_VPORT_LAG);
MLX5_COMMAND_STR_CASE(CREATE_TIR);
MLX5_COMMAND_STR_CASE(MODIFY_TIR);
MLX5_COMMAND_STR_CASE(DESTROY_TIR);
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 5f150c8..043d525 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -174,6 +174,12 @@ enum {
MLX5_CMD_OP_DELETE_L2_TABLE_ENTRY = 0x82b,
MLX5_CMD_OP_SET_WOL_ROL   = 0x830,
MLX5_CMD_OP_QUERY_WOL_ROL = 0x831,
+   MLX5_CMD_OP_CREATE_LAG= 0x840,
+   MLX5_CMD_OP_MODIFY_LAG= 0x841,
+   MLX5_CMD_OP_QUERY_LAG = 0x842,
+   MLX5_CMD_OP_DESTROY_LAG   = 0x843,
+   MLX5_CMD_OP_CREATE_VPORT_LAG  = 0x844,
+   MLX5_CMD_OP_DESTROY_VPORT_LAG = 0x845,
MLX5_CMD_OP_CREATE_TIR= 0x900,
MLX5_CMD_OP_MODIFY_TIR= 0x901,
MLX5_CMD_OP_DESTROY_TIR   = 0x902,
@@ -884,7 +890,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
u8 pad_tx_eth_packet[0x1];
u8 reserved_at_263[0x8];
u8 log_bf_reg_size[0x5];
-   u8 reserved_at_270[0x10];
+
+   u8 reserved_at_270[0xb];
+   u8 lag_master[0x1];
+   u8 num_lag_ports[0x4];
 
u8 reserved_at_280[0x10];
u8 max_wqe_sz_sq[0x10];
@@ -1918,7 +1927,7 @@ enum {
 
 struct mlx5_ifc_qpc_bits {
u8 state[0x4];
-   u8 reserved_at_4[0x4];
+   u8 lag_tx_port_affinity[0x4];
u8 st[0x8];
u8 reserved_at_10[0x3];
u8 

[for-next 0/30][PULL request] Mellanox mlx5 core driver updates 2016-08-20

2016-08-20 Thread Saeed Mahameed
Hi Dave and Doug,

This series contains several low level and API updates for mlx5 core
driver to be shared as base code for net-next and rdma mlx5 4.9 submissions.

>From Saeed, ten patches that refactors old layouts of firmware commands which 
were manually generated before we introduced the mlx5_ifc, now all of the 
firmware
commands inbox/outbox layouts moved to use mlx5_ifc and we remove the old
manually generated structures.  Plus to those ten patches, we add two patches
that unifies mlx5 commands execution interface and improve the driver log 
messages
in that area.

>From Hadar and Ilya, added the needed hardware bits and infrastructure for
minimum inline headers setting and encap/decap commands and capabilities,
needed for E-Switch offloads.

>From Alex and Artemy, Update mlx5_ifc for modify RQ and XRC bits.

>From Noa, Expose mlx5 link modes so they can be used in RDMA tree for rdma 
>tools.

>From Aviv, LAG support needed for RDMA.
- Add needed hardware structures, layouts and interface 
- mlx5 core driver LAG implementation
- Introduce mlx5 core driver LAG API for mlx5_ib

>From Maor, add two low level patches for mlx5 hardware sniffer QP
infrastructure bits and capabilities, plus added the name space for sniffer
steering tables.  Needed for RDMA subtree.

This series applies on top latest net-next and rdma/master, and smoothly merges 
with
the latest "Mellanox 100G mlx5 fixes 2016-08-16" series already applied into 
net branch.

The following changes since commit 29b4817d4018df78086157ea3a55c1d9424a7cfc:
Linux 4.8-rc1

are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git 
tags/shared-for-4.9

for you to fetch changes up to 87d22483ce68e609818d61e3a65361f5634c6cd6:
net/mlx5: Add sniffer namespaces

Thanks,
Saeed & Leon.

Alex Vesker (1):
  net/mlx5: Modify RQ bitmask from mlx5 ifc

Artemy Kovalyov (1):
  net/mlx5: Update struct mlx5_ifc_xrqc_bits

Aviv Heller (9):
  net/mlx5: Add HW interfaces used by LAG
  net/mlx5: Implement RoCE LAG feature
  net/mlx5: Get RoCE netdev
  net/mlx5e: Avoid port remapping of mlx5e netdev TISes
  net/mlx5: LAG and SRIOV cannot be used together
  net/mlx5: LAG demux flow table support
  net/mlx5: Add LAG flow steering namespace
  net/mlx5: Vport LAG creation support
  net/mlx5: Configure IB devices according to LAG state

Hadar Hen Zion (2):
  net/mlx5: Enable setting minimum inline header mode for VFs
  net/mlx5: Update mlx5_ifc.h for vxlan encap/decap

Ilya Lesokhin (1):
  net/mlx5: Introduce alloc_encap and dealloc_encap commands

Maor Gottlieb (2):
  net/mlx5: Introduce sniffer steering hardware capabilities
  net/mlx5: Add sniffer namespaces

Noa Osherovich (2):
  net/mlx5: Expose mlx5e_link_mode
  net/mlx5: Separate query_port_proto_oper for IB and EN

Saeed Mahameed (12):
  net/mlx5: Init/Teardown hca commands via mlx5 ifc
  net/mlx5: Access register and MAD IFC commands via mlx5 ifc
  net/mlx5: PD and UAR commands via mlx5 ifc
  net/mlx5: MCG commands via mlx5 ifc
  net/mlx5: Pages management commands via mlx5 ifc
  net/mlx5: EQ commands via mlx5 ifc
  {net,IB}/mlx5: CQ commands via mlx5 ifc
  {net,IB}/mlx5: MKey/PSV commands via mlx5 ifc
  {net,IB}/mlx5: QP/XRCD commands via mlx5 ifc
  {net,IB}/mlx5: Modify QP commands via mlx5 ifc
  net/mlx5: Unify and improve command interface
  net/mlx5: Improve driver log messages

 drivers/infiniband/hw/mlx5/cq.c| 110 ++--
 drivers/infiniband/hw/mlx5/main.c  |  13 +-
 drivers/infiniband/hw/mlx5/mlx5_ib.h   |   2 +-
 drivers/infiniband/hw/mlx5/mr.c| 184 ---
 drivers/infiniband/hw/mlx5/qp.c| 189 +++
 drivers/net/ethernet/mellanox/mlx5/core/Makefile   |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c  | 273 +-
 drivers/net/ethernet/mellanox/mlx5/core/cq.c   | 109 ++--
 drivers/net/ethernet/mellanox/mlx5/core/debugfs.c  |  50 +-
 drivers/net/ethernet/mellanox/mlx5/core/en.h   |  34 --
 .../net/ethernet/mellanox/mlx5/core/en_common.c|  23 +-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   |   3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  55 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/eq.c   |  80 ++-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  |  98 ++--
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c   | 232 
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h   |   8 +
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c  | 118 +++-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.h  |  10 +
 drivers/net/ethernet/mellanox/mlx5/core/fw.c   |  43 +-
 drivers/net/ethernet/mellanox/mlx5/core/lag.c  | 602 +
 drivers/net/ethernet/mellanox/mlx5/core/mad.c  |  41 +-
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 145 +++--
 drivers/net/ethernet/mellanox/mlx5/core/mcg.c  |  72 +--
 

[PATCH net-next 22/30] net/mlx5: Get RoCE netdev

2016-08-20 Thread Saeed Mahameed
From: Aviv Heller 

Used by IB driver for determining the IB bond
device's netdev, when LAG is active.

Returns PF0's netdev if mode is not active-backup,
or the PF netdev of the active slave when mode is
active-backup.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/lag.c | 27 +++
 include/linux/mlx5/driver.h   |  1 +
 2 files changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c 
b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
index 3bf0a7f..9523050 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -528,3 +528,30 @@ bool mlx5_lag_is_active(struct mlx5_core_dev *dev)
 }
 EXPORT_SYMBOL(mlx5_lag_is_active);
 
+struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev)
+{
+   struct net_device *ndev = NULL;
+   struct mlx5_lag *ldev;
+
+   mutex_lock(_mutex);
+   ldev = mlx5_lag_dev_get(dev);
+
+   if (!(ldev && mlx5_lag_is_bonded(ldev)))
+   goto unlock;
+
+   if (ldev->tracker.tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP) {
+   ndev = ldev->tracker.netdev_state[0].tx_enabled ?
+  ldev->pf[0].netdev : ldev->pf[1].netdev;
+   } else {
+   ndev = ldev->pf[0].netdev;
+   }
+   if (ndev)
+   dev_hold(ndev);
+
+unlock:
+   mutex_unlock(_mutex);
+
+   return ndev;
+}
+EXPORT_SYMBOL(mlx5_lag_get_roce_netdev);
+
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index ed983b8..c568dd9 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -945,6 +945,7 @@ void mlx5_unregister_interface(struct mlx5_interface *intf);
 int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id);
 
 bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
+struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);
 
 struct mlx5_profile {
u64 mask;
-- 
2.7.4



[PATCH net-next 03/30] net/mlx5: PD and UAR commands via mlx5 ifc

2016-08-20 Thread Saeed Mahameed
Remove old representation of manually created PD/UAR commands layouts
and use mlx5_ifc canonical structures and defines.

Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 drivers/net/ethernet/mellanox/mlx5/core/pd.c  | 58 +--
 drivers/net/ethernet/mellanox/mlx5/core/uar.c | 66 ++-
 2 files changed, 25 insertions(+), 99 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/pd.c
index f2d3aee..efe452c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pd.c
@@ -36,66 +36,32 @@
 #include 
 #include "mlx5_core.h"
 
-struct mlx5_alloc_pd_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   u8  rsvd[8];
-};
-
-struct mlx5_alloc_pd_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   __be32  pdn;
-   u8  rsvd[4];
-};
-
-struct mlx5_dealloc_pd_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   __be32  pdn;
-   u8  rsvd[4];
-};
-
-struct mlx5_dealloc_pd_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   u8  rsvd[8];
-};
-
 int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn)
 {
-   struct mlx5_alloc_pd_mbox_inin;
-   struct mlx5_alloc_pd_mbox_out   out;
+   u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(alloc_pd_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_PD);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
+   MLX5_SET(alloc_pd_in, in, opcode, MLX5_CMD_OP_ALLOC_PD);
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   err = err ? : mlx5_cmd_status_to_err_v2(out);
if (err)
return err;
 
-   if (out.hdr.status)
-   return mlx5_cmd_status_to_err();
-
-   *pdn = be32_to_cpu(out.pdn) & 0xff;
+   *pdn = MLX5_GET(alloc_pd_out, out, pd);
return err;
 }
 EXPORT_SYMBOL(mlx5_core_alloc_pd);
 
 int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn)
 {
-   struct mlx5_dealloc_pd_mbox_in  in;
-   struct mlx5_dealloc_pd_mbox_out out;
+   u32 out[MLX5_ST_SZ_DW(dealloc_pd_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(dealloc_pd_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DEALLOC_PD);
-   in.pdn = cpu_to_be32(pdn);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
-   if (err)
-   return err;
-
-   if (out.hdr.status)
-   return mlx5_cmd_status_to_err();
-
-   return err;
+   MLX5_SET(dealloc_pd_in, in, opcode, MLX5_CMD_OP_DEALLOC_PD);
+   MLX5_SET(dealloc_pd_in, in, pd, pdn);
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   return err ? : mlx5_cmd_status_to_err_v2(out);
 }
 EXPORT_SYMBOL(mlx5_core_dealloc_pd);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/uar.c 
b/drivers/net/ethernet/mellanox/mlx5/core/uar.c
index 5ff8af4..d0a0e0b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/uar.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/uar.c
@@ -42,73 +42,33 @@ enum {
NUM_LOW_LAT_UUARS   = 4,
 };
 
-
-struct mlx5_alloc_uar_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   u8  rsvd[8];
-};
-
-struct mlx5_alloc_uar_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   __be32  uarn;
-   u8  rsvd[4];
-};
-
-struct mlx5_free_uar_mbox_in {
-   struct mlx5_inbox_hdr   hdr;
-   __be32  uarn;
-   u8  rsvd[4];
-};
-
-struct mlx5_free_uar_mbox_out {
-   struct mlx5_outbox_hdr  hdr;
-   u8  rsvd[8];
-};
-
 int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn)
 {
-   struct mlx5_alloc_uar_mbox_in   in;
-   struct mlx5_alloc_uar_mbox_out  out;
+   u32 out[MLX5_ST_SZ_DW(alloc_uar_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(alloc_uar_in)]   = {0};
int err;
 
-   memset(, 0, sizeof(in));
-   memset(, 0, sizeof(out));
-   in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_UAR);
-   err = mlx5_cmd_exec(dev, , sizeof(in), , sizeof(out));
+   MLX5_SET(alloc_uar_in, in, opcode, MLX5_CMD_OP_ALLOC_UAR);
+   err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+   err = err ? : mlx5_cmd_status_to_err_v2(out);
if (err)
-   goto ex;
-
-   if (out.hdr.status) {
-   err = mlx5_cmd_status_to_err();
-   goto ex;
-   }
-
-   *uarn = be32_to_cpu(out.uarn) & 0xff;
+   return err;
 
-ex:
+   *uarn = MLX5_GET(alloc_uar_out, out, uar);
return err;
 }
 

[PATCH net-next 14/30] net/mlx5: Update mlx5_ifc.h for vxlan encap/decap

2016-08-20 Thread Saeed Mahameed
From: Hadar Hen Zion 

Add the required definitions related to vxlan encap/decap.

Signed-off-by: Hadar Hen Zion 
Signed-off-by: Ilya Lesokhin 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Leon Romanovsky 
---
 include/linux/mlx5/mlx5_ifc.h | 105 --
 1 file changed, 101 insertions(+), 4 deletions(-)

diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 7a8ef0a..3766110 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -212,6 +212,8 @@ enum {
MLX5_CMD_OP_DEALLOC_FLOW_COUNTER  = 0x93a,
MLX5_CMD_OP_QUERY_FLOW_COUNTER= 0x93b,
MLX5_CMD_OP_MODIFY_FLOW_TABLE = 0x93c,
+   MLX5_CMD_OP_ALLOC_ENCAP_HEADER= 0x93d,
+   MLX5_CMD_OP_DEALLOC_ENCAP_HEADER  = 0x93e,
MLX5_CMD_OP_MAX
 };
 
@@ -281,7 +283,9 @@ struct mlx5_ifc_flow_table_prop_layout_bits {
u8 modify_root[0x1];
u8 identified_miss_table_mode[0x1];
u8 flow_table_modify[0x1];
-   u8 reserved_at_7[0x19];
+   u8 encap[0x1];
+   u8 decap[0x1];
+   u8 reserved_at_9[0x17];
 
u8 reserved_at_20[0x2];
u8 log_max_ft_size[0x6];
@@ -512,7 +516,15 @@ struct mlx5_ifc_e_switch_cap_bits {
u8 nic_vport_node_guid_modify[0x1];
u8 nic_vport_port_guid_modify[0x1];
 
-   u8 reserved_at_20[0x7e0];
+   u8 vxlan_encap_decap[0x1];
+   u8 nvgre_encap_decap[0x1];
+   u8 reserved_at_22[0x9];
+   u8 log_max_encap_headers[0x5];
+   u8 reserved_2b[0x6];
+   u8 max_encap_header_size[0xa];
+
+   u8 reserved_40[0x7c0];
+
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -2067,6 +2079,8 @@ enum {
MLX5_FLOW_CONTEXT_ACTION_DROP  = 0x2,
MLX5_FLOW_CONTEXT_ACTION_FWD_DEST  = 0x4,
MLX5_FLOW_CONTEXT_ACTION_COUNT = 0x8,
+   MLX5_FLOW_CONTEXT_ACTION_ENCAP = 0x10,
+   MLX5_FLOW_CONTEXT_ACTION_DECAP = 0x20,
 };
 
 struct mlx5_ifc_flow_context_bits {
@@ -2086,7 +2100,9 @@ struct mlx5_ifc_flow_context_bits {
u8 reserved_at_a0[0x8];
u8 flow_counter_list_size[0x18];
 
-   u8 reserved_at_c0[0x140];
+   u8 encap_id[0x20];
+
+   u8 reserved_at_e0[0x120];
 
struct mlx5_ifc_fte_match_param_bits match_value;
 
@@ -4216,6 +4232,85 @@ struct mlx5_ifc_query_eq_in_bits {
u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_encap_header_in_bits {
+   u8 reserved_at_0[0x5];
+   u8 header_type[0x3];
+   u8 reserved_at_8[0xe];
+   u8 encap_header_size[0xa];
+
+   u8 reserved_at_20[0x10];
+   u8 encap_header[2][0x8];
+
+   u8 more_encap_header[0][0x8];
+};
+
+struct mlx5_ifc_query_encap_header_out_bits {
+   u8 status[0x8];
+   u8 reserved_at_8[0x18];
+
+   u8 syndrome[0x20];
+
+   u8 reserved_at_40[0xa0];
+
+   struct mlx5_ifc_encap_header_in_bits encap_header[0];
+};
+
+struct mlx5_ifc_query_encap_header_in_bits {
+   u8 opcode[0x10];
+   u8 reserved_at_10[0x10];
+
+   u8 reserved_at_20[0x10];
+   u8 op_mod[0x10];
+
+   u8 encap_id[0x20];
+
+   u8 reserved_at_60[0xa0];
+};
+
+struct mlx5_ifc_alloc_encap_header_out_bits {
+   u8 status[0x8];
+   u8 reserved_at_8[0x18];
+
+   u8 syndrome[0x20];
+
+   u8 encap_id[0x20];
+
+   u8 reserved_at_60[0x20];
+};
+
+struct mlx5_ifc_alloc_encap_header_in_bits {
+   u8 opcode[0x10];
+   u8 reserved_at_10[0x10];
+
+   u8 reserved_at_20[0x10];
+   u8 op_mod[0x10];
+
+   u8 reserved_at_40[0xa0];
+
+   struct mlx5_ifc_encap_header_in_bits encap_header;
+};
+
+struct mlx5_ifc_dealloc_encap_header_out_bits {
+   u8 status[0x8];
+   u8 reserved_at_8[0x18];
+
+   u8 syndrome[0x20];
+
+   u8 reserved_at_40[0x40];
+};
+
+struct mlx5_ifc_dealloc_encap_header_in_bits {
+   u8 opcode[0x10];
+   u8 reserved_at_10[0x10];
+
+   u8 reserved_20[0x10];
+   u8 op_mod[0x10];
+
+   u8 encap_id[0x20];
+
+   u8 reserved_60[0x20];
+};
+
 struct mlx5_ifc_query_dct_out_bits {
u8 status[0x8];
u8 reserved_at_8[0x18];
@@ -6102,7 +6197,9 @@ struct mlx5_ifc_create_flow_table_in_bits {
 
u8 reserved_at_a0[0x20];
 
-   u8 reserved_at_c0[0x4];
+   u8 encap_en[0x1];
+   u8 decap_en[0x1];
+   u8 reserved_at_c2[0x2];
u8 

Re: [PATCH 2/2] net: ethernet: renesas: ravb: use new api ethtool_{get|set}_link_ksettings

2016-08-20 Thread Sergei Shtylyov

On 08/20/2016 01:52 AM, Philippe Reynes wrote:


The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: Philippe Reynes 

[...]

Acked-by: Sergei Shtylyov 

   Sorry for missing the sh_eth patchset. :-<

MBR, Sergei



Re: [PATCH 1/2] net: ethernet: renesas: ravb: use phydev from struct net_device

2016-08-20 Thread Sergei Shtylyov

Hello.

On 08/20/2016 01:52 AM, Philippe Reynes wrote:


The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phy_dev in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes 

[...]

Acked-by: Sergei Shtylyov 

MBR, Sergei



Re: [PATCH 0/3] hostap: Fine-tuning for a few functions

2016-08-20 Thread Arend van Spriel
On 20-08-16 18:43, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Sat, 20 Aug 2016 18:35:43 +0200
> 
> A few update suggestions were taken into account
> from static source code analysis.

Is it worth touching this old stuff especially when you are not making
any functional changes.

Regards,
Arend

> Markus Elfring (3):
>   Use memdup_user()
>   Delete an unnecessary jump label
>   Delete unnecessary variable initialisations
> 
>  .../net/wireless/intersil/hostap/hostap_ioctl.c| 36 
> --
>  1 file changed, 12 insertions(+), 24 deletions(-)
> 


Re: [PATCH -next] net: phy: Add missing of_node_put() in xgmiitorgmii_probe()

2016-08-20 Thread Andrew Lunn
On Sat, Aug 20, 2016 at 03:26:55PM +, Wei Yongjun wrote:
> This node pointer is returned by of_parse_phandle() with
> refcount incremented in this function. of_node_put() on it
> before exitting this function.

Hi Wei

You are only releasing on the error path. What about the successful
path?

Andrew

> 
> This is detected by Coccinelle semantic patch.
> 
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/net/phy/xilinx_gmii2rgmii.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c 
> b/drivers/net/phy/xilinx_gmii2rgmii.c
> index cad6e19..4f05e5e 100644
> --- a/drivers/net/phy/xilinx_gmii2rgmii.c
> +++ b/drivers/net/phy/xilinx_gmii2rgmii.c
> @@ -75,6 +75,7 @@ int xgmiitorgmii_probe(struct mdio_device *mdiodev)
>   priv->phy_dev = of_phy_find_device(phy_node);
>   if (!priv->phy_dev) {
>   dev_info(dev, "Couldn't find phydev\n");
> + of_node_put(phy_node);
>   return -EPROBE_DEFER;
>   }
> 


[PATCH 3/3] hostap: Delete unnecessary initialisations for the variable "ret"

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 18:23:14 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning of four functions.

Signed-off-by: Markus Elfring 
---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c 
b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 5942917..c37b0bb 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -2895,7 +2895,7 @@ static int prism2_ioctl_priv_monitor(struct net_device 
*dev, int *i)
 {
struct hostap_interface *iface;
local_info_t *local;
-   int ret = 0;
+   int ret;
u32 mode;
 
iface = netdev_priv(dev);
@@ -3035,7 +3035,7 @@ static int ap_mac_cmd_ioctl(local_info_t *local, int *cmd)
 static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
 {
struct prism2_download_param *param;
-   int ret = 0;
+   int ret;
 
if (p->length < sizeof(struct prism2_download_param) ||
p->length > 1024 || !p->pointer)
@@ -3791,7 +3791,7 @@ static int prism2_ioctl_scan_req(local_info_t *local,
 static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
 {
struct prism2_hostapd_param *param;
-   int ret = 0;
+   int ret;
int ap_ioctl = 0;
 
if (p->length < sizeof(struct prism2_hostapd_param) ||
@@ -3954,7 +3954,7 @@ int hostap_ioctl(struct net_device *dev, struct ifreq 
*ifr, int cmd)
struct iwreq *wrq = (struct iwreq *) ifr;
struct hostap_interface *iface;
local_info_t *local;
-   int ret = 0;
+   int ret;
 
iface = netdev_priv(dev);
local = iface->local;
-- 
2.9.3



[PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 18:21:29 +0200

Remove a jump label which is unneeded in this function at the end.

Signed-off-by: Markus Elfring 
---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c 
b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 4e271f9..5942917 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -3835,14 +3835,12 @@ static int prism2_ioctl_priv_hostapd(local_info_t 
*local, struct iw_point *p)
}
 
if (ret == 1 || !ap_ioctl) {
-   if (copy_to_user(p->pointer, param, p->length)) {
+   if (copy_to_user(p->pointer, param, p->length))
ret = -EFAULT;
-   goto out;
-   } else if (ap_ioctl)
+   else if (ap_ioctl)
ret = 0;
}
 
- out:
kfree(param);
return ret;
 }
-- 
2.9.3



[PATCH 1/3] hostap: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 18:19:43 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 .../net/wireless/intersil/hostap/hostap_ioctl.c| 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c 
b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 3e5fa78..4e271f9 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -3041,14 +3041,9 @@ static int prism2_ioctl_priv_download(local_info_t 
*local, struct iw_point *p)
p->length > 1024 || !p->pointer)
return -EINVAL;
 
-   param = kmalloc(p->length, GFP_KERNEL);
-   if (param == NULL)
-   return -ENOMEM;
-
-   if (copy_from_user(param, p->pointer, p->length)) {
-   ret = -EFAULT;
-   goto out;
-   }
+   param = memdup_user(p->pointer, p->length);
+   if (IS_ERR(param))
+   return PTR_ERR(param);
 
if (p->length < sizeof(struct prism2_download_param) +
param->num_areas * sizeof(struct prism2_download_area)) {
@@ -3803,14 +3798,9 @@ static int prism2_ioctl_priv_hostapd(local_info_t 
*local, struct iw_point *p)
p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
return -EINVAL;
 
-   param = kmalloc(p->length, GFP_KERNEL);
-   if (param == NULL)
-   return -ENOMEM;
-
-   if (copy_from_user(param, p->pointer, p->length)) {
-   ret = -EFAULT;
-   goto out;
-   }
+   param = memdup_user(p->pointer, p->length);
+   if (IS_ERR(param))
+   return PTR_ERR(param);
 
switch (param->cmd) {
case PRISM2_SET_ENCRYPTION:
-- 
2.9.3



[PATCH 0/3] hostap: Fine-tuning for a few functions

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 18:35:43 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Use memdup_user()
  Delete an unnecessary jump label
  Delete unnecessary variable initialisations

 .../net/wireless/intersil/hostap/hostap_ioctl.c| 36 --
 1 file changed, 12 insertions(+), 24 deletions(-)

-- 
2.9.3



[PATCH v3 net-next] l2tp: Refactor the codes with existing macros instead of literal number

2016-08-20 Thread fgao
From: Gao Feng 

Use PPP_ALLSTATIONS, PPP_UI, and SEND_SHUTDOWN instead of 0xff,
0x03, and 2 separately.

Signed-off-by: Gao Feng 
---
 v3: Modify the subject;
 v2: Only replace the literal number with macros according to Guillaume's advice
 v1: Inital patch

 net/l2tp/l2tp_ppp.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index d9560aa..65e2fd6 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -177,7 +177,7 @@ static int pppol2tp_recv_payload_hook(struct sk_buff *skb)
if (!pskb_may_pull(skb, 2))
return 1;
 
-   if ((skb->data[0] == 0xff) && (skb->data[1] == 0x03))
+   if ((skb->data[0] == PPP_ALLSTATIONS) && (skb->data[1] == PPP_UI))
skb_pull(skb, 2);
 
return 0;
@@ -282,7 +282,7 @@ static void pppol2tp_session_sock_put(struct l2tp_session 
*session)
 static int pppol2tp_sendmsg(struct socket *sock, struct msghdr *m,
size_t total_len)
 {
-   static const unsigned char ppph[2] = { 0xff, 0x03 };
+   static const unsigned char ppph[2] = {PPP_ALLSTATIONS, PPP_UI};
struct sock *sk = sock->sk;
struct sk_buff *skb;
int error;
@@ -369,7 +369,7 @@ error:
  */
 static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 {
-   static const u8 ppph[2] = { 0xff, 0x03 };
+   static const u8 ppph[2] = {PPP_ALLSTATIONS, PPP_UI};
struct sock *sk = (struct sock *) chan->private;
struct sock *sk_tun;
struct l2tp_session *session;
@@ -440,7 +440,7 @@ static void pppol2tp_session_close(struct l2tp_session 
*session)
BUG_ON(session->magic != L2TP_SESSION_MAGIC);
 
if (sock) {
-   inet_shutdown(sock, 2);
+   inet_shutdown(sock, SEND_SHUTDOWN);
/* Don't let the session go away before our socket does */
l2tp_session_inc_refcount(session);
}
-- 
1.9.1




[PATCH -next] net: phy: Add missing of_node_put() in xgmiitorgmii_probe()

2016-08-20 Thread Wei Yongjun
This node pointer is returned by of_parse_phandle() with
refcount incremented in this function. of_node_put() on it
before exitting this function.

This is detected by Coccinelle semantic patch.

Signed-off-by: Wei Yongjun 
---
 drivers/net/phy/xilinx_gmii2rgmii.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c 
b/drivers/net/phy/xilinx_gmii2rgmii.c
index cad6e19..4f05e5e 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -75,6 +75,7 @@ int xgmiitorgmii_probe(struct mdio_device *mdiodev)
priv->phy_dev = of_phy_find_device(phy_node);
if (!priv->phy_dev) {
dev_info(dev, "Couldn't find phydev\n");
+   of_node_put(phy_node);
return -EPROBE_DEFER;
}



Your Urgent Response

2016-08-20 Thread Mr Hassan Umra
Dear Friend,

I am Mr Hassan Umra, the director in charge of auditing and accounting section
of Bank of Africa (BOA)  West-Africa. I would like you
to indicate your interest to receive the transfer of $12.5 Million Dollars.
 
I will like you to stand as the next of kin to our late customer whose account
is presently dormant for claims. Please once you are interested kindly send
me the following details information below,

1.Your full name:...
2.Resident address:..
3.Private phone 
4.Country : 
5.Occupation:..
6.Age:. 
7.sex
I shall send you more details as soon as i hear from you.

Regards,
Mr.Hassan Umra,


[PATCH -next] cxgb4: Simplify the return expression

2016-08-20 Thread Wei Yongjun
Simplify the return expression.

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 2bb804c..5a82eea 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2922,7 +2922,6 @@ EXPORT_SYMBOL(cxgb4_create_server_filter);
 int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid,
unsigned int queue, bool ipv6)
 {
-   int ret;
struct filter_entry *f;
struct adapter *adap;
 
@@ -2936,11 +2935,7 @@ int cxgb4_remove_server_filter(const struct net_device 
*dev, unsigned int stid,
/* Unlock the filter */
f->locked = 0;
 
-   ret = delete_filter(adap, stid);
-   if (ret)
-   return ret;
-
-   return 0;
+   return delete_filter(adap, stid);
 }
 EXPORT_SYMBOL(cxgb4_remove_server_filter);
 





[PATCH iproute2] ip: route: fix multicast route dumps

2016-08-20 Thread Nikolay Aleksandrov
If we have multicast routes and do ip route show table all we'll get the
following output:
 ...
 multicast ???/32 from ???/32  table default  proto static  iif eth0
The "???" are because the rtm_family is set to RTNL_FAMILY_IPMR instead
(or RTNL_FAMILY_IP6MR for ipv6). Add a simple workaround that returns the
real family based on the rtm_type (always RTN_MULTICAST for ipmr routes)
and the rtm_family. Similar workaround is already used in ipmroute, and
we can use this helper there as well.

After the patch the output is:
multicast 239.10.10.10/32 from 0.0.0.0/32  table default  proto static  iif eth0

Also fix a minor whitespace error and switch to tabs.

Reported-by: Satish Ashok 
Signed-off-by: Nikolay Aleksandrov 
---
 include/utils.h |  1 +
 ip/ipmroute.c   |  2 +-
 ip/iproute.c| 12 +++-
 lib/utils.c |  9 +
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/include/utils.h b/include/utils.h
index 82f1aa7de16a..1b4f939cbd8c 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -249,5 +249,6 @@ int do_each_netns(int (*func)(char *nsname, void *arg), 
void *arg,
 
 char *int_to_str(int val, char *buf);
 int get_guid(__u64 *guid, const char *arg);
+int get_real_family(int rtm_type, int rtm_family);
 
 #endif /* __UTILS_H__ */
diff --git a/ip/ipmroute.c b/ip/ipmroute.c
index 5d6922a23ae6..133367a2388d 100644
--- a/ip/ipmroute.c
+++ b/ip/ipmroute.c
@@ -112,7 +112,7 @@ int print_mroute(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
return 0;
}
 
-   family = r->rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6;
+   family = get_real_family(r->rtm_type, r->rtm_family);
 
if (n->nlmsg_type == RTM_DELROUTE)
fprintf(fp, "Deleted ");
diff --git a/ip/iproute.c b/ip/iproute.c
index 3da23af9fdff..6af55dab1526 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -311,7 +311,7 @@ int print_route(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
struct rtmsg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr *tb[RTA_MAX+1];
-   int host_len;
+   int host_len, family;
__u32 table;
 
SPRINT_BUF(b1);
@@ -363,13 +363,14 @@ int print_route(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
fprintf(fp, "%s ", rtnl_rtntype_n2a(r->rtm_type, b1, 
sizeof(b1)));
 
if (tb[RTA_DST]) {
+   family = get_real_family(r->rtm_type, r->rtm_family);
if (r->rtm_dst_len != host_len) {
fprintf(fp, "%s/%u ",
-   rt_addr_n2a_rta(r->rtm_family, tb[RTA_DST]),
+   rt_addr_n2a_rta(family, tb[RTA_DST]),
r->rtm_dst_len);
} else {
fprintf(fp, "%s ",
-   format_host_rta(r->rtm_family, tb[RTA_DST]));
+   format_host_rta(family, tb[RTA_DST]));
}
} else if (r->rtm_dst_len) {
fprintf(fp, "0/%d ", r->rtm_dst_len);
@@ -377,13 +378,14 @@ int print_route(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
fprintf(fp, "default ");
}
if (tb[RTA_SRC]) {
+   family = get_real_family(r->rtm_type, r->rtm_family);
if (r->rtm_src_len != host_len) {
fprintf(fp, "from %s/%u ",
-   rt_addr_n2a_rta(r->rtm_family, tb[RTA_SRC]),
+   rt_addr_n2a_rta(family, tb[RTA_SRC]),
r->rtm_src_len);
} else {
fprintf(fp, "from %s ",
-   format_host_rta(r->rtm_family, tb[RTA_SRC]));
+   format_host_rta(family, tb[RTA_SRC]));
}
} else if (r->rtm_src_len) {
fprintf(fp, "from 0/%u ", r->rtm_src_len);
diff --git a/lib/utils.c b/lib/utils.c
index 966047460af1..9ada7737f14d 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1156,3 +1156,12 @@ int get_guid(__u64 *guid, const char *arg)
 
return 0;
 }
+
+/* This is a necessary workaround for multicast route dumps */
+int get_real_family(int rtm_type, int rtm_family)
+{
+   if (rtm_type != RTN_MULTICAST)
+   return rtm_family;
+
+   return rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6;
+}
-- 
2.1.4



Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread Shmulik Ladkani
Hi,

On Sat, 20 Aug 2016 09:34:56 +0200 SF Markus Elfring 
 wrote:
> From: Markus Elfring 
> Date: Sat, 20 Aug 2016 08:54:15 +0200
> 
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 

Reviewed-by: Shmulik Ladkani 


wan-lmc: Improving source code formatting

2016-08-20 Thread SF Markus Elfring
Hello,

The Coccinelle software pointed out that the function "lmc_ioctl"
is an update candidate according to the message "opportunity for memdup_user".
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/wan/lmc/lmc_main.c?id=6040e57658eee6eb1315a26119101ca832d1f854#n486

I guess that it would be nice to improve also this implementation.
But there are further constraints to consider. The script "checkpatch.pl"
can point information out like the following.

* ERROR: code indent should use tabs where possible

* WARNING: please, no spaces at the start of a line


The source files for this software module contain also some open issues
for the preferred source code formatting.

* How should these places be fixed so that they will match the current
  Linux coding style before additional adjustments can be safely tried?

* Would you like to suggest any advanced tools (besides "scripts/cleanfile")
  for a corresponding source code beautification?
  Which pretty-printing approaches are acceptable for Linux so far?

Regards,
Markus


[PATCH v2 0/4] meson: Meson8b and GXBB DWMAC glue driver

2016-08-20 Thread Martin Blumenstingl
This adds a DWMAC glue driver for the PRG_ETHERNET registers found in
Meson8b and GXBB SoCs. Based on the "old" meson6b-dwmac glue driver
the register layout is completely different.
Thus I introduced a separate driver.

Changes since v1:
- make clkin1 mandatory because the internal mux expects two clocks
  (in other words: this makes the driver consistent with how the
  hardware actually works)
- expose the MPLL2 clock for use by DT so we can pass it to the ethmac
- added a .remove function to the glue driver which disables and
  unprepares the clocks on driver removal


Martin Blumenstingl (4):
  net: dt-bindings: Document the new Meson8b and GXBB DWMAC bindings
  clk: gxbb: expose MPLL2 clock for use by DT
  net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC
  ARM64: dts: meson-gxbb: use the new GXBB DWMAC glue driver

 .../devicetree/bindings/net/meson-dwmac.txt|  45 ++-
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi|   8 +-
 drivers/clk/meson/gxbb.h   |   2 +-
 drivers/net/ethernet/stmicro/stmmac/Makefile   |   2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c| 329 +
 include/dt-bindings/clock/gxbb-clkc.h  |   1 +
 6 files changed, 374 insertions(+), 13 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c

-- 
2.9.3



[PATCH v2 4/4] ARM64: dts: meson-gxbb: use the new GXBB DWMAC glue driver

2016-08-20 Thread Martin Blumenstingl
The Amlogic reference driver uses the "mc_val" devicetree property to
configure the PRG_ETHERNET_ADDR0 register. Unfortunately it uses magic
values for this configuration.
According to the datasheet the PRG_ETHERNET_ADDR0 register is at address
0xc8834108. However, the reference driver uses 0xc8834540 instead.
According to my tests, the value from the reference driver is correct.

No changes are required to the board dts files because the only
required configuration option is the phy-mode, which had to be
configured correctly before as well.

Signed-off-by: Martin Blumenstingl 
---
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi 
b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 4f42316..ab817d3 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -373,13 +373,15 @@
};
 
ethmac: ethernet@c941 {
-   compatible = "amlogic,meson6-dwmac", "snps,dwmac";
+   compatible = "amlogic,meson-gxbb-dwmac", "snps,dwmac";
reg = <0x0 0xc941 0x0 0x1
   0x0 0xc8834540 0x0 0x4>;
interrupts = <0 8 1>;
interrupt-names = "macirq";
-   clocks = < CLKID_ETH>;
-   clock-names = "stmmaceth";
+   clocks = < CLKID_ETH>,
+< CLKID_FCLK_DIV2>,
+< CLKID_MPLL2>;
+   clock-names = "stmmaceth", "clkin0", "clkin1";
phy-mode = "rgmii";
status = "disabled";
};
-- 
2.9.3



[PATCH v2 1/4] net: dt-bindings: Document the new Meson8b and GXBB DWMAC bindings

2016-08-20 Thread Martin Blumenstingl
This patch adds the documentation for the DWMAC ethernet controller
found in Amlogic Meson 8b (S805) and GXBB (S905) SoCs.
The main difference between the Meson6 glue is that different registers
(with different layout) are used.

Signed-off-by: Martin Blumenstingl 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/net/meson-dwmac.txt| 45 ++
 1 file changed, 37 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/meson-dwmac.txt 
b/Documentation/devicetree/bindings/net/meson-dwmac.txt
index ec633d7..89e62dd 100644
--- a/Documentation/devicetree/bindings/net/meson-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/meson-dwmac.txt
@@ -1,18 +1,32 @@
 * Amlogic Meson DWMAC Ethernet controller
 
 The device inherits all the properties of the dwmac/stmmac devices
-described in the file net/stmmac.txt with the following changes.
+described in the file stmmac.txt in the current directory with the
+following changes.
 
-Required properties:
+Required properties on all platforms:
 
-- compatible: should be "amlogic,meson6-dwmac" along with "snps,dwmac"
- and any applicable more detailed version number
- described in net/stmmac.txt
+- compatible:  Depending on the platform this should be one of:
+   - "amlogic,meson6-dwmac"
+   - "amlogic,meson8b-dwmac"
+   - "amlogic,meson-gxbb-dwmac"
+   Additionally "snps,dwmac" and any applicable more
+   detailed version number described in net/stmmac.txt
+   should be used.
 
-- reg: should contain a register range for the dwmac controller and
-   another one for the Amlogic specific configuration
+- reg: The first register range should be the one of the DWMAC
+   controller. The second range is is for the Amlogic specific
+   configuration (for example the PRG_ETHERNET register range
+   on Meson8b and newer)
 
-Example:
+Required properties on Meson8b and newer:
+- clock-names: Should contain the following:
+   - "stmmaceth" - see stmmac.txt
+   - "clkin0" - first parent clock of the internal mux
+   - "clkin1" - second parent clock of the internal mux
+
+
+Example for Meson6:
 
ethmac: ethernet@c941 {
compatible = "amlogic,meson6-dwmac", "snps,dwmac";
@@ -23,3 +37,18 @@ Example:
clocks = <>;
clock-names = "stmmaceth";
}
+
+Example for GXBB:
+   ethmac: ethernet@c941 {
+   compatible = "amlogic,meson-gxbb-dwmac", "snps,dwmac";
+   reg = <0x0 0xc941 0x0 0x1>,
+   <0x0 0xc8834540 0x0 0x8>;
+   interrupts = <0 8 1>;
+   interrupt-names = "macirq";
+   clocks = < CLKID_ETH>,
+   < CLKID_FCLK_DIV2>,
+   < CLKID_MPLL2>;
+   clock-names = "stmmaceth", "clkin0", "clkin1";
+   phy-mode = "rgmii";
+   status = "disabled";
+   };
-- 
2.9.3



[PATCH v2 3/4] net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC

2016-08-20 Thread Martin Blumenstingl
The Ethernet controller available in Meson8b and GXBB SoCs is a Synopsys
DesignWare MAC IP core which is already supported by the stmmac driver.

In addition to the standard stmmac driver some Meson8b / GXBB specific
registers have to be configured for the PHY clocks. These SoC specific
registers are called PRG_ETHERNET_ADDR0 and PRG_ETHERNET_ADDR1 in the
datasheet.
These registers are not backwards compatible with those on Meson 6b,
which is why a new glue driver is introduced. This worked for many
boards because the bootloader programs the PRG_ETHERNET registers
correctly. Additionally the meson6-dwmac driver only sets bit 1 of
PRG_ETHERNET_ADDR0 which (according to the datasheet) is only used
during reset.

Currently all configuration values can be determined automatically,
based on the configured phy-mode (which is mandatory for the stmmac
driver). If required the tx-delay and the mux clock (so it supports
the MPLL2 clock as well) can be made configurable in the future.

Signed-off-by: Martin Blumenstingl 
Tested-by: Kevin Hilman 
---
 drivers/net/ethernet/stmicro/stmmac/Makefile   |   2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c| 329 +
 2 files changed, 330 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c

diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile 
b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 44b630c..f77edb9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -9,7 +9,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o 
ring_mode.o  \
 obj-$(CONFIG_STMMAC_PLATFORM)  += stmmac-platform.o
 obj-$(CONFIG_DWMAC_IPQ806X)+= dwmac-ipq806x.o
 obj-$(CONFIG_DWMAC_LPC18XX)+= dwmac-lpc18xx.o
-obj-$(CONFIG_DWMAC_MESON)  += dwmac-meson.o
+obj-$(CONFIG_DWMAC_MESON)  += dwmac-meson.o dwmac-meson8b.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)   += dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)+= dwmac-altr-socfpga.o
 obj-$(CONFIG_DWMAC_STI)+= dwmac-sti.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
new file mode 100644
index 000..d080512
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -0,0 +1,329 @@
+/*
+ * Amlogic Meson S805/S905 DWMAC glue layer
+ *
+ * Copyright (C) 20016 Martin Blumenstingl 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "stmmac_platform.h"
+
+#define PRG_ETH0   0x0
+
+#define PRG_ETH0_RGMII_MODEBIT(0)
+
+/* mux to choose between fclk_div2 (bit unset) and mpll2 (bit set) */
+#define PRG_ETH0_CLK_M250_SEL_SHIFT4
+#define PRG_ETH0_CLK_M250_SEL_MASK GENMASK(4, 4)
+
+#define PRG_ETH0_TXDLY_SHIFT   5
+#define PRG_ETH0_TXDLY_MASKGENMASK(6, 5)
+#define PRG_ETH0_TXDLY_OFF (0x0 << PRG_ETH0_TXDLY_SHIFT)
+#define PRG_ETH0_TXDLY_QUARTER (0x1 << PRG_ETH0_TXDLY_SHIFT)
+#define PRG_ETH0_TXDLY_HALF(0x2 << PRG_ETH0_TXDLY_SHIFT)
+#define PRG_ETH0_TXDLY_THREE_QUARTERS  (0x3 << PRG_ETH0_TXDLY_SHIFT)
+
+/* divider for the result of m250_sel */
+#define PRG_ETH0_CLK_M250_DIV_SHIFT7
+#define PRG_ETH0_CLK_M250_DIV_WIDTH3
+
+/* divides the result of m25_sel by either 5 (bit unset) or 10 (bit set) */
+#define PRG_ETH0_CLK_M25_DIV_SHIFT 10
+#define PRG_ETH0_CLK_M25_DIV_WIDTH 1
+
+#define PRG_ETH0_INVERTED_RMII_CLK BIT(11)
+#define PRG_ETH0_TX_AND_PHY_REF_CLKBIT(12)
+
+#define MUX_CLK_NUM_PARENTS2
+
+struct meson8b_dwmac {
+   struct platform_device  *pdev;
+
+   void __iomem*regs;
+
+   phy_interface_t phy_mode;
+
+   struct clk_mux  m250_mux;
+   struct clk  *m250_mux_clk;
+   struct clk  *m250_mux_parent[MUX_CLK_NUM_PARENTS];
+
+   struct clk_divider  m250_div;
+   struct clk  *m250_div_clk;
+
+   struct clk_divider  m25_div;
+   struct clk  *m25_div_clk;
+};
+
+static void meson8b_dwmac_mask_bits(struct meson8b_dwmac *dwmac, u32 reg,
+   u32 mask, u32 value)
+{
+   u32 data;
+
+   data = readl(dwmac->regs + reg);
+   data &= ~mask;
+   data |= (value & mask);
+
+   writel(data, dwmac->regs + reg);
+}
+
+static int meson8b_init_clk(struct meson8b_dwmac *dwmac)
+{
+   struct clk_init_data init;
+   

[PATCH v2 2/4] clk: gxbb: expose MPLL2 clock for use by DT

2016-08-20 Thread Martin Blumenstingl
This exposes the MPLL2 clock as this is one of the input clocks of the
ethernet controller's internal mux.

Signed-off-by: Martin Blumenstingl 
---
 drivers/clk/meson/gxbb.h  | 2 +-
 include/dt-bindings/clock/gxbb-clkc.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/meson/gxbb.h b/drivers/clk/meson/gxbb.h
index 217df51..3606e875 100644
--- a/drivers/clk/meson/gxbb.h
+++ b/drivers/clk/meson/gxbb.h
@@ -183,7 +183,7 @@
 /* CLKID_CLK81 */
 #define CLKID_MPLL0  13
 #define CLKID_MPLL1  14
-#define CLKID_MPLL2  15
+/* CLKID_MPLL2 */
 #define CLKID_DDR16
 #define CLKID_DOS17
 #define CLKID_ISA18
diff --git a/include/dt-bindings/clock/gxbb-clkc.h 
b/include/dt-bindings/clock/gxbb-clkc.h
index 7d41864..244ea6e 100644
--- a/include/dt-bindings/clock/gxbb-clkc.h
+++ b/include/dt-bindings/clock/gxbb-clkc.h
@@ -8,6 +8,7 @@
 #define CLKID_CPUCLK   1
 #define CLKID_FCLK_DIV24
 #define CLKID_CLK8112
+#define CLKID_MPLL215
 #define CLKID_ETH  36
 #define CLKID_SD_EMMC_A94
 #define CLKID_SD_EMMC_B95
-- 
2.9.3



Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread walter harms


Am 20.08.2016 08:01, schrieb SF Markus Elfring:
> From: Markus Elfring 
> Date: Sat, 20 Aug 2016 07:50:09 +0200
> 
> * Reuse existing functionality from memdup_user() instead of keeping
>   duplicate source code.
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Return directly if this copy operation failed.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
> b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> index 6388bc0..bb89f04 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> @@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char 
> __user *buf,
>   struct mlx5_core_dev *dev = filp->private_data;
>   struct mlx5_cmd_debug *dbg = >cmd.dbg;
>   void *ptr;
> - int err;
>  
>   if (*pos != 0)
>   return -EINVAL;
> @@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const 
> char __user *buf,
>   kfree(dbg->in_msg);
>   dbg->in_msg = NULL;
>   dbg->inlen = 0;
> -
> - ptr = kzalloc(count, GFP_KERNEL);
> - if (!ptr)
> - return -ENOMEM;
> -
> - if (copy_from_user(ptr, buf, count)) {
> - err = -EFAULT;
> - goto out;
> - }
> + ptr = memdup_user(buf, count);
> + if (IS_ERR(ptr))
> + return PTR_ERR(ptr);
>   dbg->in_msg = ptr;
>   dbg->inlen = count;
>  
>   *pos = count;
>  

maybe i am missing something here but why do you need ptr ?

The use of count looks even more confusing it is stored in
 dbg->inlen, *pos and is returned.
is that realy needed ?

re,
 wh

>   return count;
> -
> -out:
> - kfree(ptr);
> - return err;
>  }
>  
>  static ssize_t data_read(struct file *filp, char __user *buf, size_t count,


Re: [PATCH] wan-cosa: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread Christophe JAILLET

Le 20/08/2016 à 10:25, SF Markus Elfring a écrit :

From: Markus Elfring 
Date: Sat, 20 Aug 2016 10:10:12 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
  drivers/net/wan/cosa.c | 12 +++-
  1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index b87fe0a..02f5809 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -875,16 +875,10 @@ static ssize_t cosa_write(struct file *file,
if (count > COSA_MTU)
count = COSA_MTU;

-   /* Allocate the buffer */
-   kbuf = kmalloc(count, GFP_KERNEL|GFP_DMA);
In this case, 'memdup_user()' has a different meaning, as GFP_DMA will 
no more be used for this memory allocation.



-   if (kbuf == NULL) {
+   kbuf = memdup_user(buf, count);
+   if (IS_ERR(kbuf)) {
up(>wsem);
-   return -ENOMEM;
-   }
-   if (copy_from_user(kbuf, buf, count)) {
-   up(>wsem);
-   kfree(kbuf);
-   return -EFAULT;
+   return PTR_ERR(kbuf);
}
chan->tx_status=0;
cosa_start_tx(chan, kbuf, count);




---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus




[PATCH] wan-cosa: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 10:10:12 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/net/wan/cosa.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index b87fe0a..02f5809 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -875,16 +875,10 @@ static ssize_t cosa_write(struct file *file,
if (count > COSA_MTU)
count = COSA_MTU;

-   /* Allocate the buffer */
-   kbuf = kmalloc(count, GFP_KERNEL|GFP_DMA);
-   if (kbuf == NULL) {
+   kbuf = memdup_user(buf, count);
+   if (IS_ERR(kbuf)) {
up(>wsem);
-   return -ENOMEM;
-   }
-   if (copy_from_user(kbuf, buf, count)) {
-   up(>wsem);
-   kfree(kbuf);
-   return -EFAULT;
+   return PTR_ERR(kbuf);
}
chan->tx_status=0;
cosa_start_tx(chan, kbuf, count);
-- 
2.9.3



net/sctp: BUG: KASAN: stack-out-of-bounds in memcmp

2016-08-20 Thread Baozeng Ding
Hello all,
The following program triggers  stack-out-of-bounds in memcmp. The kernel 
version is 4.8.0-rc1+ (on Aug 13 commit 
118253a593bd1c57de2d1193df1ccffe1abe745b). Thanks.

==
BUG: KASAN: stack-out-of-bounds in memcmp+0xf8/0x120 at addr 8803f7247170
Read of size 1 by task 0/10880
page:ea000fdc91c0 count:0 mapcount:0 mapping:  (null) index:0x0
flags: 0x2fffc00()
page dumped because: kasan: bad access detected
CPU: 0 PID: 10880 Comm: 0 Tainted: GB   W   4.8.0-rc1+ #30
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
 87cb8ee0 8803f7246fb0 82cdc0a9 f7247040
 fbfff0f971dc 8803f7247040 8803f7247170 8803f72471f0
 8804841fee98 00ff 8803f7247030 817c0ba8
Call Trace:
 [< inline >] __dump_stack /lib/dump_stack.c:15
 [] dump_stack+0x12e/0x185 /lib/dump_stack.c:51
 [< inline >] print_address_description /mm/kasan/report.c:204
 [] kasan_report_error+0x498/0x4c0 /mm/kasan/report.c:283
 [] ? is_module_text_address+0x10/0x20 /kernel/module.c:4224
 [< inline >] kasan_report /mm/kasan/report.c:303
 [] __asan_report_load1_noabort+0x3e/0x40 
/mm/kasan/report.c:321
 [] ? memcmp+0xf8/0x120 /lib/string.c:768
 [] memcmp+0xf8/0x120 /lib/string.c:768
 [< inline >] find_stack /lib/stackdepot.c:176
 [] depot_save_stack+0x16d/0x5b0 /lib/stackdepot.c:224
 [] save_stack+0xb8/0xd0 /mm/kasan/kasan.c:485
 [] ? save_stack_trace+0x26/0x50 
/arch/x86/kernel/stacktrace.c:67
 [] ? save_stack+0x46/0xd0 /mm/kasan/kasan.c:479
 [< inline >] ? set_track /mm/kasan/kasan.c:491
 [] ? kasan_slab_free+0x71/0xb0 /mm/kasan/kasan.c:555
 [< inline >] ? slab_free_hook /mm/slub.c:1356
 [< inline >] ? slab_free_freelist_hook /mm/slub.c:1378
 [< inline >] ? slab_free /mm/slub.c:2936
 [] ? kfree+0x114/0x370 /mm/slub.c:3856
 [] ? skb_free_head+0x74/0xb0 /net/core/skbuff.c:580
 [] ? skb_release_data+0x33f/0x3e0 /net/core/skbuff.c:611
 [] ? skb_release_all+0x4a/0x60 /net/core/skbuff.c:670
 [< inline >] ? __kfree_skb /net/core/skbuff.c:684
 [] ? consume_skb+0x133/0x360 /net/core/skbuff.c:757
 [< inline >] ? sctp_chunk_destroy /net/sctp/sm_make_chunk.c:1447
 [] ? sctp_chunk_put+0xc6/0x180 /net/sctp/sm_make_chunk.c:1474
 [] ? sctp_chunk_free+0x53/0x60 /net/sctp/sm_make_chunk.c:1461
 [] ? sctp_inq_pop+0x6c0/0x1150 /net/sctp/inqueue.c:150
 [] ? sctp_assoc_bh_rcv+0xd1/0x490 /net/sctp/associola.c:1018
 [] ? sctp_inq_push+0x12c/0x190 /net/sctp/inqueue.c:95
 [] ? sctp_backlog_rcv+0xe4/0xa60 /net/sctp/input.c:342
 [< inline >] ? sk_backlog_rcv /./include/net/sock.h:872
 [] ? __release_sock+0x127/0x3a0 /net/core/sock.c:2063
 [] ? release_sock+0x59/0x1c0 /net/core/sock.c:2521
 [] ? sctp_wait_for_connect+0x2f5/0x510 
/net/sctp/socket.c:7525
 [] ? sctp_sendmsg+0x2041/0x30b0 /net/sctp/socket.c:1984
 [] ? inet_sendmsg+0x2f5/0x4c0 /net/ipv4/af_inet.c:740
 [< inline >] ? sock_sendmsg_nosec /net/socket.c:609
 [] ? sock_sendmsg+0xca/0x110 /net/socket.c:619
 [] ? ___sys_sendmsg+0x2bf/0x880 /net/socket.c:1942
 [] ? __sys_sendmmsg+0x159/0x380 /net/socket.c:2032
 [< inline >] ? SYSC_sendmmsg /net/socket.c:2061
 [] ? SyS_sendmmsg+0x35/0x60 /net/socket.c:2056
 [] ? entry_SYSCALL_64_fastpath+0x23/0xc1 
/arch/x86/entry/entry_64.S:207
 [] ? sctp_outq_uncork+0x5a/0x70 /net/sctp/outqueue.c:786
 [] ? hugetlb_cgroup_migrate+0x420/0x420 ??:?
 [] ? trace_hardirqs_on+0xd/0x10 
/kernel/locking/lockdep.c:2740
 [< inline >] ? spin_unlock_irqrestore /./include/linux/spinlock.h:362
 [] ? __delete_object+0x9d/0x100 /mm/kmemleak.c:638
 [] ? skb_free_head+0x74/0xb0 /net/core/skbuff.c:580
 [] ? call_rcu_sched+0x12/0x20 /kernel/rcu/tree.c:3191
 [] ? put_object+0x42/0x60 /mm/kmemleak.c:474
 [] ? __delete_object+0xa5/0x100 /mm/kmemleak.c:639
 [< inline >] set_track /mm/kasan/kasan.c:491
 [] kasan_slab_free+0x71/0xb0 /mm/kasan/kasan.c:555
 [] ? skb_free_head+0x74/0xb0 /net/core/skbuff.c:580
 [< inline >] slab_free_hook /mm/slub.c:1356
 [< inline >] slab_free_freelist_hook /mm/slub.c:1378
 [< inline >] slab_free /mm/slub.c:2936
 [] kfree+0x114/0x370 /mm/slub.c:3856
 [] skb_free_head+0x74/0xb0 /net/core/skbuff.c:580
 [] skb_release_data+0x33f/0x3e0 /net/core/skbuff.c:611
 [] skb_release_all+0x4a/0x60 /net/core/skbuff.c:670
 [< inline >] __kfree_skb /net/core/skbuff.c:684
 [] consume_skb+0x133/0x360 /net/core/skbuff.c:757
 [< inline >] sctp_chunk_destroy /net/sctp/sm_make_chunk.c:1447
 [] sctp_chunk_put+0xc6/0x180 /net/sctp/sm_make_chunk.c:1474
 [] sctp_chunk_free+0x53/0x60 /net/sctp/sm_make_chunk.c:1461
 [] sctp_inq_pop+0x6c0/0x1150 /net/sctp/inqueue.c:150
 [] sctp_assoc_bh_rcv+0xd1/0x490 /net/sctp/associola.c:1018
 [] sctp_inq_push+0x12c/0x190 /net/sctp/inqueue.c:95
 [] sctp_backlog_rcv+0xe4/0xa60 /net/sctp/input.c:342
 [] 

[PATCH 2/2] tun: Rename a jump label in update_filter()

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 09:00:34 +0200

Adjust a jump target according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/net/tun.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a1aeccb..e249428 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -753,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void 
__user *arg)
for (; n < uf.count; n++) {
if (!is_multicast_ether_addr(addr[n].u)) {
err = 0; /* no filter */
-   goto done;
+   goto free_addr;
}
addr_hash_set(filter->mask, addr[n].u);
}
@@ -769,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void 
__user *arg)
 
/* Return the number of exact filters */
err = nexact;
-
-done:
+free_addr:
kfree(addr);
return err;
 }
-- 
2.9.3



[PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 08:54:15 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/net/tun.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 9c8b5bc..a1aeccb 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void 
__user *arg)
}
 
alen = ETH_ALEN * uf.count;
-   addr = kmalloc(alen, GFP_KERNEL);
-   if (!addr)
-   return -ENOMEM;
-
-   if (copy_from_user(addr, arg + sizeof(uf), alen)) {
-   err = -EFAULT;
-   goto done;
-   }
+   addr = memdup_user(arg + sizeof(uf), alen);
+   if (IS_ERR(addr))
+   return PTR_ERR(addr);
 
/* The filter is updated without holding any locks. Which is
 * perfectly safe. We disable it first and in the worst
-- 
2.9.3



[PATCH 0/2] tun: Fine-tuning for update_filter()

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 09:16:16 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use memdup_user()
  Rename a jump label

 drivers/net/tun.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

-- 
2.9.3



[net-next 11/15] i40e: Initialize pointer in client_release function

2016-08-20 Thread Jeff Kirsher
From: Harshitha Ramamurthy 

The function i40e_client_release has a print statement that uses an
adapter pointer which is not initialized if a previous if statement
is not true. Hence, intialize it in the right place.

Change-ID: I1afdaa2c46771ac42be56edcc41bb56b455b06c8
Signed-off-by: Harshitha Ramamurthy 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c 
b/drivers/net/ethernet/intel/i40e/i40e_client.c
index 1035f88..09a37cf 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.c
@@ -662,7 +662,7 @@ int i40e_lan_del_device(struct i40e_pf *pf)
 static int i40e_client_release(struct i40e_client *client)
 {
struct i40e_client_instance *cdev, *tmp;
-   struct i40e_pf *pf = NULL;
+   struct i40e_pf *pf;
int ret = 0;
 
LIST_HEAD(cdevs_tmp);
@@ -672,12 +672,12 @@ static int i40e_client_release(struct i40e_client *client)
if (strncmp(cdev->client->name, client->name,
I40E_CLIENT_STR_LENGTH))
continue;
+   pf = (struct i40e_pf *)cdev->lan_info.pf;
if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, >state)) {
if (atomic_read(>ref_cnt) > 0) {
ret = I40E_ERR_NOT_READY;
goto out;
}
-   pf = (struct i40e_pf *)cdev->lan_info.pf;
if (client->ops && client->ops->close)
client->ops->close(>lan_info, client,
   false);
-- 
2.7.4



[net-next 12/15] i40e: Remove XSTRINGIFY macro definitions and uses

2016-08-20 Thread Jeff Kirsher
From: Joe Perches 

Use __stringify instead.

Signed-off-by: Joe Perches 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e.h| 4 
 drivers/net/ethernet/intel/i40e/i40e_client.h | 6 +++---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h 
b/drivers/net/ethernet/intel/i40e/i40e.h
index 8dc98c2..747ef2d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -120,10 +120,6 @@
 #define I40E_CURRENT_NVM_VERSION_HI 0x2
 #define I40E_CURRENT_NVM_VERSION_LO 0x40
 
-/* magic for getting defines into strings */
-#define STRINGIFY(foo)  #foo
-#define XSTRINGIFY(bar) STRINGIFY(bar)
-
 #define I40E_RX_DESC(R, i) \
(&(((union i40e_32byte_rx_desc *)((R)->desc))[i]))
 #define I40E_TX_DESC(R, i) \
diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.h 
b/drivers/net/ethernet/intel/i40e/i40e_client.h
index a4601d9..38a6c36 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.h
@@ -36,9 +36,9 @@
 #define I40E_CLIENT_VERSION_MINOR 01
 #define I40E_CLIENT_VERSION_BUILD 00
 #define I40E_CLIENT_VERSION_STR \
-   XSTRINGIFY(I40E_CLIENT_VERSION_MAJOR) "." \
-   XSTRINGIFY(I40E_CLIENT_VERSION_MINOR) "." \
-   XSTRINGIFY(I40E_CLIENT_VERSION_BUILD)
+   __stringify(I40E_CLIENT_VERSION_MAJOR) "." \
+   __stringify(I40E_CLIENT_VERSION_MINOR) "." \
+   __stringify(I40E_CLIENT_VERSION_BUILD)
 
 struct i40e_client_version {
u8 major;
-- 
2.7.4



[net-next 13/15] i40e: Correcting mutex usage in client code

2016-08-20 Thread Jeff Kirsher
From: Avinash Dayanand 

Correcting the mutex usage, in client_subtask(), mutex_unlock has
to be called just before client_del_instance() since this function opens
and later closes the same mutex again.
Similarly in client_is_registered removing the mutex since it closes
the mutex twice.

This is a patch suggested by RDMA team.

Change-ID: Icce519c266e4221b8a2a72a15ba5bf01750e5852
Signed-off-by: Avinash Dayanand 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c 
b/drivers/net/ethernet/intel/i40e/i40e_client.c
index 09a37cf..5404b32 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.c
@@ -576,6 +576,7 @@ void i40e_client_subtask(struct i40e_pf *pf)
set_bit(__I40E_CLIENT_INSTANCE_OPENED, >state);
} else {
/* remove client instance */
+   mutex_unlock(_client_instance_mutex);
i40e_client_del_instance(pf, client);
atomic_dec(>ref_cnt);
continue;
-- 
2.7.4



Re: [PATCH net 2/2] sctp: not copying duplicate addrs to the assoc's bind address list

2016-08-20 Thread Xin Long
> Ah, I see what you're doing.  Ok, this makes some sense, at least on the 
> receive
> side, when you get a cookie unpacked and modify the remote peers address list,
> it makes sense to check for duplicates.  On the local side however, I would,
> instead of checking it when the list gets copied, I'd check it when the master
> list gets updated (in the NETDEV_UP event notifier for the local address list,

I was thinking about to check it in the NETDEV_UP, yes it can make the
master list has no duplicated addresses.  But what if two same addresses
events come, and they come from different NICs (though I can't point  out
the valid use case), then we filter there.

Later, sctp may receive one  NETDEV_DOWN event,sctp will remove that
addr in the master list, but it shouldn't have been removed, as another local
NIC still has that addr.

That's why I have to leave the master alone, just check when they are really
being bind to asoc addr list.

> and the sctp_add_bind_addr function for the endpoint address list).  That way

As to the endpoint address list, sctp has different process for binding
the address 'ANY' from assoc address list (note that this issue only
happened in binding the address 'ANY'). instead of  copying the master
address list to  the endpoint, it only adds address 'ANY' to the EP
address list. Only when starting a connection and create the assoc, it
copy the master address list to ASOC.

So no need to do it in sctp_add_bind_addr for endpoint address list.
Besides, sctp_add_bind_addr  is supposed to be called after checking
the duplicated address(I got it from sctp_do_bind()). :-)

> you can keep that nested for loop out of the send path on the local system.
>
>


Re: [PATCH 1/1] ppp: Fix one deadlock issue of PPP when reentrant

2016-08-20 Thread Feng Gao
On Sat, Aug 20, 2016 at 5:48 AM, Guillaume Nault  wrote:
> On Fri, Aug 19, 2016 at 11:16:41PM +0800, f...@ikuai8.com wrote:
>> From: Gao Feng 
>>
>> PPP channel holds one spinlock before send frame. But the skb may
>> select the same PPP channel with wrong route policy. As a result,
>> the skb reaches the same channel path. It tries to get the same
>> spinlock which is held before. Bang, the deadlock comes out.
>>
>> Now add one lock owner to avoid it like xmit_lock_owner of
>> netdev_queue. Check the lock owner before try to get the spinlock.
>> If the current cpu is already the owner, it means ppp finds there is
>> one reentrant and returns directly. If not owner and hold the spinlock
>> successfully, it sets owner with current CPU ID.
>>
>> The following is the panic stack of 3.3.8. But the same issue
>> should be in the upstream too.
>>
>> [] ? _raw_spin_lock_bh+0x11/0x40
>> [] ppp_unregister_channel+0x1347/0x2170 [ppp_generic]
>> [] ? kmem_cache_free+0xa7/0xc0
>> [] ppp_unregister_channel+0x1db7/0x2170 [ppp_generic]
>> [] ppp_unregister_channel+0x2065/0x2170 [ppp_generic]
>> [] dev_hard_start_xmit+0x4cd/0x620
>> [] sch_direct_xmit+0x74/0x1d0
>> [] dev_queue_xmit+0x1d/0x30
>> [] neigh_direct_output+0xc/0x10
>> [] ip_finish_output+0x25e/0x2b0
>> [] ip_output+0x88/0x90
>> [] ? __ip_local_out+0x9f/0xb0
>> [] ip_local_out+0x24/0x30
>> [] 0xa00b9744
>> [] ppp_unregister_channel+0x20f8/0x2170 [ppp_generic]
>> [] ppp_output_wakeup+0x122/0x11d0 [ppp_generic]
>> [] vfs_write+0xb8/0x160
>> [] sys_write+0x45/0x90
>> [] system_call_fastpath+0x16/0x1b
>>
>> The call flow is like this.
>> ppp_write->ppp_channel_push->start_xmit->select inappropriate route
>>  -> dev_hard_start_xmit->ppp_start_xmit->ppp_xmit_process->
>> ppp_push. Now ppp_push tries to get the same spinlock which is held
>> in ppp_channel_push.
>>
>> Although the PPP deadlock is caused by inappropriate route policy
>> with L2TP, I think it is not accepted the PPP module would cause kernel
>> deadlock with wrong route policy.
>>
>> Signed-off-by: Gao Feng 
>> ---
>>  v3: Change the fix solution. Giveup the send chance instead of recursive 
>> lock
>>  v2: Fix recursive unlock issue
>>  v1: Initial patch
>>
>>  drivers/net/ppp/ppp_generic.c | 95 
>> +--
>>  1 file changed, 73 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
>> index 70cfa06..b653f1f 100644
>> --- a/drivers/net/ppp/ppp_generic.c
>> +++ b/drivers/net/ppp/ppp_generic.c
>> @@ -162,6 +162,46 @@ struct ppp {
>>|SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
>>|SC_COMP_TCP|SC_REJ_COMP_TCP|SC_MUST_COMP)
>>
>> +struct channel_lock {
>> + spinlock_t lock;
>> + int owner;
>> +};
>> +
>> +static inline void ppp_channel_lock_init(struct channel_lock *cl)
> No need for inline in .c files.

OK. I make them as non-inline.

>
>> +{
>> + cl->owner = -1;
>> + spin_lock_init(>lock);
>> +}
>> +
>> +static inline bool ppp_channel_lock_bh(struct channel_lock *cl)
>> +{
>> + int cpu;
>> +
>> + local_bh_disable();
>> + cpu = smp_processor_id();
>> + if (cpu == cl->owner) {
>> + /* The CPU already holds this channel lock and sends. But the
>> +  * channel is selected after inappropriate route. It causes
>> +  * reenter the channel again. It is forbidden by PPP module.
>> +  */
>> + if (net_ratelimit())
>> + pr_err("PPP detects one recursive channel send\n");
>> + local_bh_enable();
> What about calling local_bh_enable() before logging the error?

Ok.

>
>> + return false;
>> + }
>> + spin_lock(>lock);
>> + cl->owner = cpu;
>> +
>> + return true;
>> +}
>> +
>> +static inline void ppp_channel_unlock_bh(struct channel_lock *cl)
>> +{
>> + cl->owner = -1;
>> + spin_unlock(>lock);
>> + local_bh_enable();
>> +}
>> +
>>  /*
>>   * Private data structure for each channel.
>>   * This includes the data structure used for multilink.
>> @@ -171,7 +211,7 @@ struct channel {
>>   struct list_head list;  /* link in all/new_channels list */
>>   struct ppp_channel *chan;   /* public channel data structure */
>>   struct rw_semaphore chan_sem;   /* protects `chan' during chan ioctl */
>> - spinlock_t  downl;  /* protects `chan', file.xq dequeue */
>> + struct channel_lock downl;  /* protects `chan', file.xq dequeue */
>>   struct ppp  *ppp;   /* ppp unit we're connected to */
>>   struct net  *chan_net;  /* the net channel belongs to */
>>   struct list_head clist; /* link in list of channels per unit */
>
>> @@ -1645,6 +1687,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct 
>> sk_buff *skb)
>>   struct channel *pch;
>>   struct sk_buff *frag;
>>  

[net-next 15/15] i40evf: Open RDMA Client after reset

2016-08-20 Thread Jeff Kirsher
From: Avinash Dayanand 

RDMA client is closed during the PF reset and needs to be opened again.
Setting the flag so that RDMA client is opened in watchdog() function.

Change-ID: I507b1e4cbd05528cdff68fd360ef3dcac8901263
Signed-off-by: Avinash Dayanand 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 24f88ec..f751f7b 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1804,6 +1804,8 @@ continue_reset:
}
adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER;
adapter->aq_required |= I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
+   /* Open RDMA Client again */
+   adapter->aq_required |= I40EVF_FLAG_SERVICE_CLIENT_REQUESTED;
clear_bit(__I40EVF_IN_CRITICAL_TASK, >crit_section);
i40evf_misc_irq_enable(adapter);
 
-- 
2.7.4



[net-next 14/15] i40e/i40evf: Fix indentation

2016-08-20 Thread Jeff Kirsher
Several defines and code comments were indented with spaces instead
of tabs, correct the issue to make indentation consistent.

Change-ID: I0dc6bbb990ec4a9e856acc9ec526d876181f092c
Signed-off-by: Jeff Kirsher 
Tested-by: Andrew Bowers 
---
 drivers/net/ethernet/intel/i40e/i40e.h | 131 +++--
 drivers/net/ethernet/intel/i40evf/i40evf.h |  57 +++--
 2 files changed, 96 insertions(+), 92 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h 
b/drivers/net/ethernet/intel/i40e/i40e.h
index 747ef2d..19103a6 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -65,72 +65,72 @@
 #include "i40e_dcb.h"
 
 /* Useful i40e defaults */
-#define I40E_MAX_VEB  16
-
-#define I40E_MAX_NUM_DESCRIPTORS  4096
-#define I40E_MAX_CSR_SPACE (4 * 1024 * 1024 - 64 * 1024)
-#define I40E_DEFAULT_NUM_DESCRIPTORS  512
-#define I40E_REQ_DESCRIPTOR_MULTIPLE  32
-#define I40E_MIN_NUM_DESCRIPTORS  64
-#define I40E_MIN_MSIX 2
-#define I40E_DEFAULT_NUM_VMDQ_VSI 8 /* max 256 VSIs */
-#define I40E_MIN_VSI_ALLOC51 /* LAN, ATR, FCOE, 32 VF, 16 VMDQ */
+#define I40E_MAX_VEB   16
+
+#define I40E_MAX_NUM_DESCRIPTORS   4096
+#define I40E_MAX_CSR_SPACE (4 * 1024 * 1024 - 64 * 1024)
+#define I40E_DEFAULT_NUM_DESCRIPTORS   512
+#define I40E_REQ_DESCRIPTOR_MULTIPLE   32
+#define I40E_MIN_NUM_DESCRIPTORS   64
+#define I40E_MIN_MSIX  2
+#define I40E_DEFAULT_NUM_VMDQ_VSI  8 /* max 256 VSIs */
+#define I40E_MIN_VSI_ALLOC 51 /* LAN, ATR, FCOE, 32 VF, 16 VMDQ */
 /* max 16 qps */
 #define i40e_default_queues_per_vmdq(pf) \
(((pf)->flags & I40E_FLAG_RSS_AQ_CAPABLE) ? 4 : 1)
-#define I40E_DEFAULT_QUEUES_PER_VF4
-#define I40E_DEFAULT_QUEUES_PER_TC1 /* should be a power of 2 */
+#define I40E_DEFAULT_QUEUES_PER_VF 4
+#define I40E_DEFAULT_QUEUES_PER_TC 1 /* should be a power of 2 */
 #define i40e_pf_get_max_q_per_tc(pf) \
(((pf)->flags & I40E_FLAG_128_QP_RSS_CAPABLE) ? 128 : 64)
-#define I40E_FDIR_RING0
-#define I40E_FDIR_RING_COUNT  32
+#define I40E_FDIR_RING 0
+#define I40E_FDIR_RING_COUNT   32
 #ifdef I40E_FCOE
-#define I40E_DEFAULT_FCOE 8 /* default number of QPs for FCoE */
-#define I40E_MINIMUM_FCOE 1 /* minimum number of QPs for FCoE */
+#define I40E_DEFAULT_FCOE  8 /* default number of QPs for FCoE */
+#define I40E_MINIMUM_FCOE  1 /* minimum number of QPs for FCoE */
 #endif /* I40E_FCOE */
-#define I40E_MAX_AQ_BUF_SIZE  4096
-#define I40E_AQ_LEN   256
-#define I40E_AQ_WORK_LIMIT66 /* max number of VFs + a little */
-#define I40E_MAX_USER_PRIORITY8
-#define I40E_DEFAULT_MSG_ENABLE   4
-#define I40E_QUEUE_WAIT_RETRY_LIMIT   10
-#define I40E_INT_NAME_STR_LEN(IFNAMSIZ + 16)
+#define I40E_MAX_AQ_BUF_SIZE   4096
+#define I40E_AQ_LEN256
+#define I40E_AQ_WORK_LIMIT 66 /* max number of VFs + a little */
+#define I40E_MAX_USER_PRIORITY 8
+#define I40E_DEFAULT_MSG_ENABLE4
+#define I40E_QUEUE_WAIT_RETRY_LIMIT10
+#define I40E_INT_NAME_STR_LEN  (IFNAMSIZ + 16)
 
 /* Ethtool Private Flags */
-#defineI40E_PRIV_FLAGS_MFP_FLAGBIT(0)
-#defineI40E_PRIV_FLAGS_LINKPOLL_FLAG   BIT(1)
+#define I40E_PRIV_FLAGS_MFP_FLAG   BIT(0)
+#define I40E_PRIV_FLAGS_LINKPOLL_FLAG  BIT(1)
 #define I40E_PRIV_FLAGS_FD_ATR BIT(2)
 #define I40E_PRIV_FLAGS_VEB_STATS  BIT(3)
 #define I40E_PRIV_FLAGS_HW_ATR_EVICT   BIT(4)
 #define I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT   BIT(5)
 
-#define I40E_NVM_VERSION_LO_SHIFT  0
-#define I40E_NVM_VERSION_LO_MASK   (0xff << I40E_NVM_VERSION_LO_SHIFT)
-#define I40E_NVM_VERSION_HI_SHIFT  12
-#define I40E_NVM_VERSION_HI_MASK   (0xf << I40E_NVM_VERSION_HI_SHIFT)
-#define I40E_OEM_VER_BUILD_MASK0x
-#define I40E_OEM_VER_PATCH_MASK0xff
-#define I40E_OEM_VER_BUILD_SHIFT   8
-#define I40E_OEM_VER_SHIFT 24
+#define I40E_NVM_VERSION_LO_SHIFT  0
+#define I40E_NVM_VERSION_LO_MASK   (0xff << I40E_NVM_VERSION_LO_SHIFT)
+#define I40E_NVM_VERSION_HI_SHIFT  12
+#define I40E_NVM_VERSION_HI_MASK   (0xf << I40E_NVM_VERSION_HI_SHIFT)
+#define I40E_OEM_VER_BUILD_MASK0x
+#define I40E_OEM_VER_PATCH_MASK0xff
+#define I40E_OEM_VER_BUILD_SHIFT   8
+#define I40E_OEM_VER_SHIFT 24
 #define I40E_PHY_DEBUG_ALL \
(I40E_AQ_PHY_DEBUG_DISABLE_LINK_FW | \
I40E_AQ_PHY_DEBUG_DISABLE_ALL_LINK_FW)
 
 /* The values in here are decimal coded as hex as is the case in the NVM map*/
-#define I40E_CURRENT_NVM_VERSION_HI 0x2
-#define I40E_CURRENT_NVM_VERSION_LO 0x40
+#define 

[PATCH net-next] cxgb4/cxgb4vf: Add support for IFLA_VF_VLAN

2016-08-20 Thread Hariprasad Shenai
Adds support for ndo_set_vf_vlan for cxgb4 driver

Signed-off-by: Hariprasad Shenai 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 6b0528913687..f354f90d7faa 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1572,6 +1572,7 @@ void t4_idma_monitor(struct adapter *adapter,
 int hz, int ticks);
 int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
  unsigned int naddr, u8 *addr);
+int t4_set_vf_vlan_acl(struct adapter *adapter, unsigned int vf, u16 vlan);
 void uld_mem_free(struct adapter *adap);
 int uld_mem_alloc(struct adapter *adap);
 void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl 
*fl);
-- 
2.3.4



Re: [PATCH v1 1/1] l2tp: Use existing macros instead of literal number

2016-08-20 Thread Feng Gao
Sorry, I forget to modify the title.
I will sent another update.

On Sat, Aug 20, 2016 at 2:28 AM, Guillaume Nault  wrote:
> On Fri, Aug 19, 2016 at 05:55:26PM +0800, f...@ikuai8.com wrote:
>> From: Gao Feng 
>>
>> 1. Use PPP_ALLSTATIONS/PPP_UI instead of literal 0xff/0x03;
>> 2. Use one static const global fixed_ppphdr instead of two same
>> static variable ppph in two different functions;
>> 3. Use SEND_SHUTDOWN instead of literal 2;
>>
>> Signed-off-by: Gao Feng 
>> ---
>>  v1: Initial patch
>>
> v1 again?
>
> BTW, no need to number your patch for a single patch series.
> But you have to tell which tree is the series for.
>
> So instead of [PATCH v1 1/1], you should send [PATCH v2 net-next].


[net-next 08/15] i40e: Add support for HMC resource and profile for X722

2016-08-20 Thread Jeff Kirsher
From: Carolyn Wyborny 

This patch adds support for HMC resource and profile cmds for X722
firmware.

Change-ID: Icc332101f38ab15d1bfa167823100eb4f6822f7e
Signed-off-by: Carolyn Wyborny 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h   | 21 +
 drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h | 21 +
 2 files changed, 42 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h 
b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
index 5c4bf76..67e396b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
@@ -204,6 +204,9 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_suspend_port_tx= 0x041B,
i40e_aqc_opc_resume_port_tx = 0x041C,
i40e_aqc_opc_configure_partition_bw = 0x041D,
+   /* hmc */
+   i40e_aqc_opc_query_hmc_resource_profile = 0x0500,
+   i40e_aqc_opc_set_hmc_resource_profile   = 0x0501,
 
/* phy commands*/
i40e_aqc_opc_get_phy_abilities  = 0x0600,
@@ -1586,6 +1589,24 @@ struct i40e_aqc_configure_partition_bw_data {
 
 I40E_CHECK_STRUCT_LEN(0x22, i40e_aqc_configure_partition_bw_data);
 
+/* Get and set the active HMC resource profile and status.
+ * (direct 0x0500) and (direct 0x0501)
+ */
+struct i40e_aq_get_set_hmc_resource_profile {
+   u8  pm_profile;
+   u8  pe_vf_enabled;
+   u8  reserved[14];
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aq_get_set_hmc_resource_profile);
+
+enum i40e_aq_hmc_profile {
+   /* I40E_HMC_PROFILE_NO_CHANGE   = 0, reserved */
+   I40E_HMC_PROFILE_DEFAULT= 1,
+   I40E_HMC_PROFILE_FAVOR_VF   = 2,
+   I40E_HMC_PROFILE_EQUAL  = 3,
+};
+
 /* Get PHY Abilities (indirect 0x0600) uses the generic indirect struct */
 
 /* set in param0 for get phy abilities to report qualified modules */
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h 
b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
index 0045650..40b0eaf 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
@@ -204,6 +204,9 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_suspend_port_tx= 0x041B,
i40e_aqc_opc_resume_port_tx = 0x041C,
i40e_aqc_opc_configure_partition_bw = 0x041D,
+   /* hmc */
+   i40e_aqc_opc_query_hmc_resource_profile = 0x0500,
+   i40e_aqc_opc_set_hmc_resource_profile   = 0x0501,
 
/* phy commands*/
i40e_aqc_opc_get_phy_abilities  = 0x0600,
@@ -1583,6 +1586,24 @@ struct i40e_aqc_configure_partition_bw_data {
 
 I40E_CHECK_STRUCT_LEN(0x22, i40e_aqc_configure_partition_bw_data);
 
+/* Get and set the active HMC resource profile and status.
+ * (direct 0x0500) and (direct 0x0501)
+ */
+struct i40e_aq_get_set_hmc_resource_profile {
+   u8  pm_profile;
+   u8  pe_vf_enabled;
+   u8  reserved[14];
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aq_get_set_hmc_resource_profile);
+
+enum i40e_aq_hmc_profile {
+   /* I40E_HMC_PROFILE_NO_CHANGE   = 0, reserved */
+   I40E_HMC_PROFILE_DEFAULT= 1,
+   I40E_HMC_PROFILE_FAVOR_VF   = 2,
+   I40E_HMC_PROFILE_EQUAL  = 3,
+};
+
 /* Get PHY Abilities (indirect 0x0600) uses the generic indirect struct */
 
 /* set in param0 for get phy abilities to report qualified modules */
-- 
2.7.4



[net-next 07/15] i40e: Fix byte ordering in ARP NS code for X722

2016-08-20 Thread Jeff Kirsher
From: Carolyn Wyborny 

This patch fixes byte ordering problems found when enabling this feature
support. Without this patch, the feature will not work correctly. This
patch fixes the definitions to have the correct byte order.

Change-ID: Ic7489fbcbe2195df7be62ff5e359201b827cefe6
Signed-off-by: Carolyn Wyborny 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h  | 38 --
 .../net/ethernet/intel/i40evf/i40e_adminq_cmd.h| 38 --
 2 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h 
b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
index 11cf1a5..5c4bf76 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
@@ -450,13 +450,15 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_cppm_configuration);
 /* Set ARP Proxy command / response (indirect 0x0104) */
 struct i40e_aqc_arp_proxy_data {
__le16  command_flags;
-#define I40E_AQ_ARP_INIT_IPV4  0x0008
-#define I40E_AQ_ARP_UNSUP_CTL  0x0010
-#define I40E_AQ_ARP_ENA0x0020
-#define I40E_AQ_ARP_ADD_IPV4   0x0040
-#define I40E_AQ_ARP_DEL_IPV4   0x0080
+#define I40E_AQ_ARP_INIT_IPV4  0x0800
+#define I40E_AQ_ARP_UNSUP_CTL  0x1000
+#define I40E_AQ_ARP_ENA0x2000
+#define I40E_AQ_ARP_ADD_IPV4   0x4000
+#define I40E_AQ_ARP_DEL_IPV4   0x8000
__le16  table_id;
-   __le32  pfpm_proxyfc;
+   __le32  enabled_offloads;
+#define I40E_AQ_ARP_DIRECTED_OFFLOAD_ENABLE0x0020
+#define I40E_AQ_ARP_OFFLOAD_ENABLE 0x0800
__le32  ip_addr;
u8  mac_addr[6];
u8  reserved[2];
@@ -471,17 +473,19 @@ struct i40e_aqc_ns_proxy_data {
__le16  table_idx_ipv6_0;
__le16  table_idx_ipv6_1;
__le16  control;
-#define I40E_AQ_NS_PROXY_ADD_0 0x0100
-#define I40E_AQ_NS_PROXY_DEL_0 0x0200
-#define I40E_AQ_NS_PROXY_ADD_1 0x0400
-#define I40E_AQ_NS_PROXY_DEL_1 0x0800
-#define I40E_AQ_NS_PROXY_ADD_IPV6_00x1000
-#define I40E_AQ_NS_PROXY_DEL_IPV6_00x2000
-#define I40E_AQ_NS_PROXY_ADD_IPV6_10x4000
-#define I40E_AQ_NS_PROXY_DEL_IPV6_10x8000
-#define I40E_AQ_NS_PROXY_COMMAND_SEQ   0x0001
-#define I40E_AQ_NS_PROXY_INIT_IPV6_TBL 0x0002
-#define I40E_AQ_NS_PROXY_INIT_MAC_TBL  0x0004
+#define I40E_AQ_NS_PROXY_ADD_0 0x0001
+#define I40E_AQ_NS_PROXY_DEL_0 0x0002
+#define I40E_AQ_NS_PROXY_ADD_1 0x0004
+#define I40E_AQ_NS_PROXY_DEL_1 0x0008
+#define I40E_AQ_NS_PROXY_ADD_IPV6_00x0010
+#define I40E_AQ_NS_PROXY_DEL_IPV6_00x0020
+#define I40E_AQ_NS_PROXY_ADD_IPV6_10x0040
+#define I40E_AQ_NS_PROXY_DEL_IPV6_10x0080
+#define I40E_AQ_NS_PROXY_COMMAND_SEQ   0x0100
+#define I40E_AQ_NS_PROXY_INIT_IPV6_TBL 0x0200
+#define I40E_AQ_NS_PROXY_INIT_MAC_TBL  0x0400
+#define I40E_AQ_NS_PROXY_OFFLOAD_ENABLE0x0800
+#define I40E_AQ_NS_PROXY_DIRECTED_OFFLOAD_ENABLE   0x1000
u8  mac_addr_0[6];
u8  mac_addr_1[6];
u8  local_mac_addr[6];
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h 
b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
index 3114dcf..0045650 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
@@ -447,13 +447,15 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_cppm_configuration);
 /* Set ARP Proxy command / response (indirect 0x0104) */
 struct i40e_aqc_arp_proxy_data {
__le16  command_flags;
-#define I40E_AQ_ARP_INIT_IPV4  0x0008
-#define I40E_AQ_ARP_UNSUP_CTL  0x0010
-#define I40E_AQ_ARP_ENA0x0020
-#define I40E_AQ_ARP_ADD_IPV4   0x0040
-#define I40E_AQ_ARP_DEL_IPV4   0x0080
+#define I40E_AQ_ARP_INIT_IPV4  0x0800
+#define I40E_AQ_ARP_UNSUP_CTL  0x1000
+#define I40E_AQ_ARP_ENA0x2000
+#define I40E_AQ_ARP_ADD_IPV4   0x4000
+#define I40E_AQ_ARP_DEL_IPV4   0x8000
__le16  table_id;
-   __le32  pfpm_proxyfc;
+   __le32  enabled_offloads;
+#define I40E_AQ_ARP_DIRECTED_OFFLOAD_ENABLE0x0020
+#define I40E_AQ_ARP_OFFLOAD_ENABLE 0x0800
__le32  ip_addr;
u8  mac_addr[6];
u8  reserved[2];
@@ -468,17 +470,19 @@ struct i40e_aqc_ns_proxy_data {
__le16  table_idx_ipv6_0;
__le16  table_idx_ipv6_1;
__le16  control;
-#define I40E_AQ_NS_PROXY_ADD_0 0x0100
-#define I40E_AQ_NS_PROXY_DEL_0 0x0200
-#define I40E_AQ_NS_PROXY_ADD_1 0x0400
-#define I40E_AQ_NS_PROXY_DEL_1 0x0800
-#define I40E_AQ_NS_PROXY_ADD_IPV6_00x1000
-#define I40E_AQ_NS_PROXY_DEL_IPV6_00x2000
-#define I40E_AQ_NS_PROXY_ADD_IPV6_10x4000
-#define I40E_AQ_NS_PROXY_DEL_IPV6_10x8000
-#define I40E_AQ_NS_PROXY_COMMAND_SEQ   0x0001
-#define 

[net-next 09/15] i40e: use matching format identifiers

2016-08-20 Thread Jeff Kirsher
From: Heinrich Schuchardt 

i is defined as int but output as %u several times.
Adjust the format identifiers.

Signed-off-by: Heinrich Schuchardt 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c 
b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 5bd3848..1835186 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -1560,13 +1560,13 @@ static void i40e_get_strings(struct net_device *netdev, 
u32 stringset,
}
 #endif
for (i = 0; i < vsi->num_queue_pairs; i++) {
-   snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
+   snprintf(p, ETH_GSTRING_LEN, "tx-%d.tx_packets", i);
p += ETH_GSTRING_LEN;
-   snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
+   snprintf(p, ETH_GSTRING_LEN, "tx-%d.tx_bytes", i);
p += ETH_GSTRING_LEN;
-   snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
+   snprintf(p, ETH_GSTRING_LEN, "rx-%d.rx_packets", i);
p += ETH_GSTRING_LEN;
-   snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
+   snprintf(p, ETH_GSTRING_LEN, "rx-%d.rx_bytes", i);
p += ETH_GSTRING_LEN;
}
if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
@@ -1581,16 +1581,16 @@ static void i40e_get_strings(struct net_device *netdev, 
u32 stringset,
}
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
snprintf(p, ETH_GSTRING_LEN,
-"veb.tc_%u_tx_packets", i);
+"veb.tc_%d_tx_packets", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
-"veb.tc_%u_tx_bytes", i);
+"veb.tc_%d_tx_bytes", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
-"veb.tc_%u_rx_packets", i);
+"veb.tc_%d_rx_packets", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
-"veb.tc_%u_rx_bytes", i);
+"veb.tc_%d_rx_bytes", i);
p += ETH_GSTRING_LEN;
}
}
@@ -1601,23 +1601,23 @@ static void i40e_get_strings(struct net_device *netdev, 
u32 stringset,
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
-"port.tx_priority_%u_xon", i);
+"port.tx_priority_%d_xon", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
-"port.tx_priority_%u_xoff", i);
+"port.tx_priority_%d_xoff", i);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
-"port.rx_priority_%u_xon", i);
+"port.rx_priority_%d_xon", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
-"port.rx_priority_%u_xoff", i);
+"port.rx_priority_%d_xoff", i);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
-"port.rx_priority_%u_xon_2_xoff", i);
+"port.rx_priority_%d_xon_2_xoff", i);
p += ETH_GSTRING_LEN;
}
/* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
-- 
2.7.4



[net-next 10/15] i40e: Check client is open before calling client ops

2016-08-20 Thread Jeff Kirsher
From: Catherine Sullivan 

We were having a race between the completion of the client open and
calls to the client ops so don't call a client op unless we are sure the
client is open.

Change-Id: I741f4f2aa4fcbfdad3e40da1b005856c396b
Signed-off-by: Catherine Sullivan 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c 
b/drivers/net/ethernet/intel/i40e/i40e_client.c
index 677dae5..1035f88 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.c
@@ -148,6 +148,11 @@ i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 
vf_id, u8 *msg, u16 len)
"Cannot locate client instance virtual 
channel receive routine\n");
continue;
}
+   if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+ >state)) {
+   dev_dbg(>back->pdev->dev, "Client is not 
open, abort virtchnl_receive\n");
+   continue;
+   }
cdev->client->ops->virtchnl_receive(>lan_info,
cdev->client,
vf_id, msg, len);
@@ -181,6 +186,11 @@ void i40e_notify_client_of_l2_param_changes(struct 
i40e_vsi *vsi)
"Cannot locate client instance 
l2_param_change routine\n");
continue;
}
+   if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+ >state)) {
+   dev_dbg(>back->pdev->dev, "Client is not 
open, abort l2 param change\n");
+   continue;
+   }
cdev->lan_info.params = params;
cdev->client->ops->l2_param_change(>lan_info,
   cdev->client,
@@ -298,6 +308,11 @@ void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, 
u32 vf_id)
"Cannot locate client instance VF reset 
routine\n");
continue;
}
+   if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+ >state)) {
+   dev_dbg(>pdev->dev, "Client is not open, 
abort vf-reset\n");
+   continue;
+   }
cdev->client->ops->vf_reset(>lan_info,
cdev->client, vf_id);
}
@@ -328,6 +343,11 @@ void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, 
u32 num_vfs)
"Cannot locate client instance VF 
enable routine\n");
continue;
}
+   if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+ >state)) {
+   dev_dbg(>pdev->dev, "Client is not open, 
abort vf-enable\n");
+   continue;
+   }
cdev->client->ops->vf_enable(>lan_info,
 cdev->client, num_vfs);
}
@@ -362,6 +382,11 @@ int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id,
"Cannot locate client instance VF 
capability routine\n");
continue;
}
+   if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+ >state)) {
+   dev_dbg(>pdev->dev, "Client is not open, 
abort vf-capable\n");
+   continue;
+   }
capable = cdev->client->ops->vf_capable(>lan_info,
cdev->client,
vf_id);
-- 
2.7.4



[net-next 02/15] i40e: fix broken i40e_config_rss_aq function

2016-08-20 Thread Jeff Kirsher
From: Jacob Keller 

X722 hardware requires using the admin queue to configure RSS. This
function was previously re-written in commit e69ff813af35 ("i40e: rework
the functions to configure RSS with similar parameters").
However, the previous refactor did not work correctly for a few reasons

(a) it does not check whether seed is NULL before using it, resulting in
a NULL pointer dereference

[  402.954721] BUG: unable to handle kernel NULL pointer dereference at 
  (null)
[  402.955568] IP: [] 
i40e_config_rss_aq.constprop.65+0x2f/0x1c0 [i40e]
[  402.956402] PGD ad610067 PUD accc0067 PMD 0
[  402.957235] Oops:  [#1] SMP
[  402.958064] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 
xt_conntrack ip_set nfnetlink ebtable_filter ebtable_
broute bridge stp llc ebtable_nat ebtables ip6table_mangle ip6table_raw 
ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv
6 ip6table_security ip6table_filter ip6_tables iptable_mangle iptable_raw 
iptable_nat nf_conntrack_ipv4_ nf_defrag_ipv4_ nf_nat_ip
v4_ nf_nat nf_conntrack iptable_security intel_rapl i86_kg_temp_thermal 
coretemp kvm_intel kvm irqbypass crct10dif_clMl crc32_
pclMl ghash_clMlni_intel iTCO_wdt iTCO_vendor_support shpchp sb_edac dcdbas 
pcspkr joydev ipmi_devintf wmi edac_core ipmi_ssif
 acpi_ad acpi_ower_meter ipmi_si ipmi_msghandler mei_me nfsd lpc_ich mei 
ioatdma tpm_tis auth_rpcgss tpm nfs_acl lockd grace s
unrpc ifs nngag200 i2c_algo_bit drm_kms_helper ttm drm iigbe bnx2x i40e dca 
mdio ptp pps_core libcrc32c fjes crc32c_intel
[  402.965563] CPU: 22 PID: 2461 Conm: ethtool Not tainted 
4.6.0-rc7_1.2-ABNidQ+ #20
[  402.966719] Hardware name: Dell Inc. PowerEdge R720/0C4Y3R, BIOS 2.5.2 
01/28/2015
[  402.967862] task: 880219b51dc0 ti: 8800b3408000 task.ti: 
8800b3408000
[  402.969046] RIP: 0010:[]  [] 
i40e_config_rss_aq.constprop.65+0x2f/0x1c0 [i40e]
[  402.970339] RSP: 0018:8800b340ba90  EFLAGS: 00010246
[  402.971616] RAX:  RBX: 88042ec14000 RCX: 0200
[  402.972961] RDX: 880428eb9200 RSI:  RDI: 88042ec14000
[  402.974312] RBP: 8800b340baf8 R08: 880237ada8f0 R09: 880428eb9200
[  402.975709] R10: 880428eb9200 R11:  R12: 88042ec2e000
[  402.977104] R13: 88042ec2e000 R14: 88042ec14000 R15: 88022ea00800
[  402.978541] FS:  7f84fd054700() GS:880237ac() 
knlGS:
[  402.980003] CS:  0010 DS:  ES:  CR0: 80050033
[  402.981508] CR2:  CR3: 3289e000 CR4: 000406e0
[  402.983028] Stack:
[  402.984578]  02000200  88023ffeda68 
88023ffef000
[  402.986187]  0268 8800b340bbf8 88023ffedd80 
88ce4f1d
[  402.987844]  88042ec14000 88022ea00800 88042ec2e000 
88042ec14000
[  402.989509] Call Trace:
[  402.991200]  [] i40e_config_rss+0x11f/0x1c0 [i40e]
[  402.992924]  [] i40e_set_rifh+0ic0/0x130 [i40e]
[  402.994684]  [] ethtool_set_rifh+0x1f7/0x300
[  402.996446]  [] ? cred_has_capability+0io6b/0x100
[  402.998203]  [] ? selinux_capable+0x12/0x20
[  402.68]  [] ? security_capable+0x4b/0x70
[  403.001707]  [] dev_ethtool+0x1423/0x2290
[  403.003461]  [] dev_ioctl+0x191/0io630
[  403.005186]  [] ? lru_cache_add+0x3a/0i80
[  403.006942]  [] ? _raw_spin_unlock+0ie/0x20
[  403.008691]  [] sock_do_ioctl+0x45/0i50
[  403.010421]  [] sock_ioctl+0x209/0x2d0
[  403.012173]  [] do_vfs_ioctl+0u4/0io6c0
[  403.013911]  [] SyS_ioctl+0x79/0x90
[  403.015710]  [] entry_SYSCALL_64_fastpath+0x1a/0u4
[  403.017500] Code: 90 55 48 89 e5 41 57 41 56 41 55 41 54 53 48 89 fb 48 83 
ec 40 4c 8b a7 e0 05 00 00 65 48 8b 04 25 28 00 00 00 48 89 45 d0 31 c0 <48> 8b 
06 41 0f b7 bc 24 f2 0f 00 00 48 89 45 9c 48 8b 46 08 48
[  403.021454] RIP  [] 
i40e_config_rss_aq.constprop.65+0x2f/0x1c0 [i40e]
[  403.023395]  RSP 
[  403.025271] CR2: 
[  403.027169] ---[ end trace 64561b528cf61cf0 ]---

(b) it does not even bother to use the passed in *lut parameter which
defines the requested lookup table. Instead it uses its own round robin
table.

Fix these issues by re-writing it to be similar to i40e_config_rss_reg
and i40e_get_rss_aq.

Fixes: e69ff813af35 ("i40e: rework the functions to configure RSS with similar 
parameters", 2015-10-21)
Signed-off-by: Jacob Keller 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 57 -
 1 file changed, 23 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 1692a89..2ed1e8b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7985,45 +7985,34 @@ static int i40e_setup_misc_vector(struct i40e_pf *pf)
 static int 

[net-next 05/15] i40evf: report link speed

2016-08-20 Thread Jeff Kirsher
From: Mitch Williams 

The PF driver tells us the link speed, so do something with that
information. Add link speed to log messages, and report speed through
ethtool.

Change-Id: I279dc9540cc5203376406050a3e8d67e128d5882
Signed-off-by: Mitch Williams 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40evf/i40evf.h |  1 +
 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 26 --
 .../net/ethernet/intel/i40evf/i40evf_virtchnl.c| 55 ++
 3 files changed, 70 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf.h 
b/drivers/net/ethernet/intel/i40evf/i40evf.h
index 76ed97d..6fa00f3 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf.h
+++ b/drivers/net/ethernet/intel/i40evf/i40evf.h
@@ -258,6 +258,7 @@ struct i40evf_adapter {
struct work_struct watchdog_task;
bool netdev_registered;
bool link_up;
+   enum i40e_aq_link_speed link_speed;
enum i40e_virtchnl_ops current_op;
 #define CLIENT_ENABLED(_a) ((_a)->vf_res ? \
(_a)->vf_res->vf_offload_flags & \
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
index c9c202f..e17a154 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
@@ -74,13 +74,33 @@ static const struct i40evf_stats i40evf_gstrings_stats[] = {
 static int i40evf_get_settings(struct net_device *netdev,
   struct ethtool_cmd *ecmd)
 {
-   /* In the future the VF will be able to query the PF for
-* some information - for now use a dummy value
-*/
+   struct i40evf_adapter *adapter = netdev_priv(netdev);
+
ecmd->supported = 0;
ecmd->autoneg = AUTONEG_DISABLE;
ecmd->transceiver = XCVR_DUMMY1;
ecmd->port = PORT_NONE;
+   /* Set speed and duplex */
+   switch (adapter->link_speed) {
+   case I40E_LINK_SPEED_40GB:
+   ethtool_cmd_speed_set(ecmd, SPEED_4);
+   break;
+   case I40E_LINK_SPEED_20GB:
+   ethtool_cmd_speed_set(ecmd, SPEED_2);
+   break;
+   case I40E_LINK_SPEED_10GB:
+   ethtool_cmd_speed_set(ecmd, SPEED_1);
+   break;
+   case I40E_LINK_SPEED_1GB:
+   ethtool_cmd_speed_set(ecmd, SPEED_1000);
+   break;
+   case I40E_LINK_SPEED_100MB:
+   ethtool_cmd_speed_set(ecmd, SPEED_100);
+   break;
+   default:
+   break;
+   }
+   ecmd->duplex = DUPLEX_FULL;
 
return 0;
 }
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index d76c221..cc6cb30 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -817,6 +817,45 @@ void i40evf_set_rss_lut(struct i40evf_adapter *adapter)
 }
 
 /**
+ * i40evf_print_link_message - print link up or down
+ * @adapter: adapter structure
+ *
+ * Log a message telling the world of our wonderous link status
+ */
+static void i40evf_print_link_message(struct i40evf_adapter *adapter)
+{
+   struct net_device *netdev = adapter->netdev;
+   char *speed = "Unknown ";
+
+   if (!adapter->link_up) {
+   netdev_info(netdev, "NIC Link is Down\n");
+   return;
+   }
+
+   switch (adapter->link_speed) {
+   case I40E_LINK_SPEED_40GB:
+   speed = "40 G";
+   break;
+   case I40E_LINK_SPEED_20GB:
+   speed = "20 G";
+   break;
+   case I40E_LINK_SPEED_10GB:
+   speed = "10 G";
+   break;
+   case I40E_LINK_SPEED_1GB:
+   speed = "1000 M";
+   break;
+   case I40E_LINK_SPEED_100MB:
+   speed = "100 M";
+   break;
+   default:
+   break;
+   }
+
+   netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
+}
+
+/**
  * i40evf_request_reset
  * @adapter: adapter structure
  *
@@ -853,15 +892,13 @@ void i40evf_virtchnl_completion(struct i40evf_adapter 
*adapter,
(struct i40e_virtchnl_pf_event *)msg;
switch (vpe->event) {
case I40E_VIRTCHNL_EVENT_LINK_CHANGE:
-   adapter->link_up =
-   vpe->event_data.link_event.link_status;
-   if (adapter->link_up && !netif_carrier_ok(netdev)) {
-   dev_info(>pdev->dev, "NIC Link is 
Up\n");
-   netif_carrier_on(netdev);
-   netif_tx_wake_all_queues(netdev);
-   } else if (!adapter->link_up) {
-   

[net-next 03/15] i40e: use configured RSS key and lookup table in i40e_vsi_config_rss

2016-08-20 Thread Jeff Kirsher
From: Jacob Keller 

A previous refactor added support to store user configuration for VSIs,
so that extra VSIs such as for VMDq can use this information when
configuring. Unfortunately the i40e_vsi_config_rss function was missed
in this refactor, and the values were being ignored. Fix this by
checking for the fields and using those instead of always using the
default values.

Signed-off-by: Jacob Keller 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 2ed1e8b..4ec9565 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8076,13 +8076,26 @@ static int i40e_vsi_config_rss(struct i40e_vsi *vsi)
if (!(pf->flags & I40E_FLAG_RSS_AQ_CAPABLE))
return 0;
 
+   if (!vsi->rss_size)
+   vsi->rss_size = min_t(int, pf->alloc_rss_size,
+ vsi->num_queue_pairs);
+   if (!vsi->rss_size)
+   return -EINVAL;
+
lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
if (!lut)
return -ENOMEM;
-
-   i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size);
-   netdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);
-   vsi->rss_size = min_t(int, pf->alloc_rss_size, vsi->num_queue_pairs);
+   /* Use the user configured hash keys and lookup table if there is one,
+* otherwise use default
+*/
+   if (vsi->rss_lut_user)
+   memcpy(lut, vsi->rss_lut_user, vsi->rss_table_size);
+   else
+   i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size);
+   if (vsi->rss_hkey_user)
+   memcpy(seed, vsi->rss_hkey_user, I40E_HKEY_ARRAY_SIZE);
+   else
+   netdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);
ret = i40e_config_rss_aq(vsi, seed, lut, vsi->rss_table_size);
kfree(lut);
 
-- 
2.7.4



[net-next 06/15] i40e: refactor tail_bump check

2016-08-20 Thread Jeff Kirsher
From: Carolyn Wyborny 

This patch refactors tail bump check.

Change-ID: Ide0e19171d67d90cb2b06b8dcd4fa791ae120160
Signed-off-by: Carolyn Wyborny 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 6 ++
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c 
b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index df7ecc9..f8d6623 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -2840,10 +2840,9 @@ static inline void i40e_tx_map(struct i40e_ring 
*tx_ring, struct sk_buff *skb,
  I40E_TXD_QW1_CMD_SHIFT);
 
/* notify HW of packet */
-   if (!tail_bump)
+   if (!tail_bump) {
prefetchw(tx_desc + 1);
-
-   if (tail_bump) {
+   } else {
/* Force memory writes to complete before letting h/w
 * know there are new descriptors to fetch.  (Only
 * applicable for weak-ordered memory model archs,
@@ -2852,7 +2851,6 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, 
struct sk_buff *skb,
wmb();
writel(i, tx_ring->tail);
}
-
return;
 
 dma_error:
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c 
b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index a579193..0130458 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -2068,10 +2068,9 @@ static inline void i40evf_tx_map(struct i40e_ring 
*tx_ring, struct sk_buff *skb,
  I40E_TXD_QW1_CMD_SHIFT);
 
/* notify HW of packet */
-   if (!tail_bump)
+   if (!tail_bump) {
prefetchw(tx_desc + 1);
-
-   if (tail_bump) {
+   } else {
/* Force memory writes to complete before letting h/w
 * know there are new descriptors to fetch.  (Only
 * applicable for weak-ordered memory model archs,
@@ -2080,7 +2079,6 @@ static inline void i40evf_tx_map(struct i40e_ring 
*tx_ring, struct sk_buff *skb,
wmb();
writel(i, tx_ring->tail);
}
-
return;
 
 dma_error:
-- 
2.7.4



[net-next 01/15] i40e: move i40e_vsi_config_rss below i40e_get_rss_aq

2016-08-20 Thread Jeff Kirsher
From: Jacob Keller 

Move this function below the two functions related to configuring RSS
via the admin queue. This helps co-locate the two functions, and made it
easier to spot a bug in the first i40e_config_rss_aq function as
compared to the i40e_get_rss_aq function.

Signed-off-by: Jacob Keller 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 54 ++---
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 798c4e2..1692a89 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8028,33 +8028,6 @@ config_rss_aq_out:
 }
 
 /**
- * i40e_vsi_config_rss - Prepare for VSI(VMDq) RSS if used
- * @vsi: VSI structure
- **/
-static int i40e_vsi_config_rss(struct i40e_vsi *vsi)
-{
-   u8 seed[I40E_HKEY_ARRAY_SIZE];
-   struct i40e_pf *pf = vsi->back;
-   u8 *lut;
-   int ret;
-
-   if (!(pf->flags & I40E_FLAG_RSS_AQ_CAPABLE))
-   return 0;
-
-   lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
-   if (!lut)
-   return -ENOMEM;
-
-   i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size);
-   netdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);
-   vsi->rss_size = min_t(int, pf->alloc_rss_size, vsi->num_queue_pairs);
-   ret = i40e_config_rss_aq(vsi, seed, lut, vsi->rss_table_size);
-   kfree(lut);
-
-   return ret;
-}
-
-/**
  * i40e_get_rss_aq - Get RSS keys and lut by using AQ commands
  * @vsi: Pointer to vsi structure
  * @seed: Buffter to store the hash keys
@@ -8101,6 +8074,33 @@ static int i40e_get_rss_aq(struct i40e_vsi *vsi, const 
u8 *seed,
 }
 
 /**
+ * i40e_vsi_config_rss - Prepare for VSI(VMDq) RSS if used
+ * @vsi: VSI structure
+ **/
+static int i40e_vsi_config_rss(struct i40e_vsi *vsi)
+{
+   u8 seed[I40E_HKEY_ARRAY_SIZE];
+   struct i40e_pf *pf = vsi->back;
+   u8 *lut;
+   int ret;
+
+   if (!(pf->flags & I40E_FLAG_RSS_AQ_CAPABLE))
+   return 0;
+
+   lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
+   if (!lut)
+   return -ENOMEM;
+
+   i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size);
+   netdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);
+   vsi->rss_size = min_t(int, pf->alloc_rss_size, vsi->num_queue_pairs);
+   ret = i40e_config_rss_aq(vsi, seed, lut, vsi->rss_table_size);
+   kfree(lut);
+
+   return ret;
+}
+
+/**
  * i40e_config_rss_reg - Configure RSS keys and lut by writing registers
  * @vsi: Pointer to vsi structure
  * @seed: RSS hash seed
-- 
2.7.4



[net-next 04/15] i40e: use alloc_workqueue instead of create_singlethread_workqueue

2016-08-20 Thread Jeff Kirsher
From: Jacob Keller 

Replace calls to create_singlethread_workqueue instead with alloc_workqueue
as is style with other Intel drivers. This provides more control over
workqueue creation, and allows explicit setting of the desired mode of
operation. It also makes it more obvious that driver name constant is
passed to a format "%s".

Change-ID: I6192b44caf5140336cd54c5b350d51c73b541fdb
Signed-off-by: Jacob Keller 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ++-
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 4ec9565..f355c04 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -11605,7 +11605,8 @@ static int __init i40e_init_module(void)
 * it can't be any worse than using the system workqueue which
 * was already single threaded
 */
-   i40e_wq = create_singlethread_workqueue(i40e_driver_name);
+   i40e_wq = alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1,
+ i40e_driver_name);
if (!i40e_wq) {
pr_err("%s: Failed to create workqueue\n", i40e_driver_name);
return -ENOMEM;
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index ba046d1..24f88ec 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -2833,7 +2833,8 @@ static int __init i40evf_init_module(void)
 
pr_info("%s\n", i40evf_copyright);
 
-   i40evf_wq = create_singlethread_workqueue(i40evf_driver_name);
+   i40evf_wq = alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1,
+   i40evf_driver_name);
if (!i40evf_wq) {
pr_err("%s: Failed to create workqueue\n", i40evf_driver_name);
return -ENOMEM;
-- 
2.7.4



[net-next 00/15][pull request] 40GbE Intel Wired LAN Driver Updates 2016-08-19

2016-08-20 Thread Jeff Kirsher
This series contains updates to i40e and i40evf only.

Jake provides several patches, first just moves a function to co-locate
the two functions related to configuring RSS via the admin queue, which
should help in spotting bugs when comparing the two functions.  Fixed
an issue where commit e69ff813af35 ("i40e: rework the functions to
configure RSS with similar parameters") missed checking whether the seed
is NULL before using it and did not use the passed in *lut parameter.
Fixed an issue where a previous refactor missed i40e_vsi_config_rss()
and the values were being ignored, so checked for the fields and used
them instead of default values.  Lastly replaced calls to
create_singlethread_workqueue() with alloc_workqueue() to provide more
control over workqueue creation and allows explicit setting of the
desired mode of operation.

Mitch adds link speed to log messages and reports speed through ethtool.

Carolyn refactors tail bump check and fixes byte ordering problems found
when enabling this feature support.  Adds support for HMC resources and
profile commands for x722 firmware.

Heinrich Schuchardt fixes format identifiers from %u to %d since the
variable is defined as an integer.

Catherine fixes an issue where there was a race condition between the
completion of the client open and calls to the client ops, so ensured
that client ops are not called until we are sure client is open.

Harshitha makes sure that i40e_client_release() does not try to use
an adapter pointer which may not be initialized, so make sure it is.

Joe Perches fixes the use of the local macro XSTRINGIFY() to use
__stringify() instead.

Avinash corrects the mutex usage in client_subtask().  Fixed the RDMA
client to open again after reset since it is closed during a PF reset.

Jeff (me) clean up whitespace issues, where indentation was done
inconsistently and with spaces versus tabs.

The following are changes since commit dc833def42e7f2425f69d83a53bee054e80caea5:
  net/irda: remove pointless assignment/check
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 40GbE

Avinash Dayanand (2):
  i40e: Correcting mutex usage in client code
  i40evf: Open RDMA Client after reset

Carolyn Wyborny (3):
  i40e: refactor tail_bump check
  i40e: Fix byte ordering in ARP NS code for X722
  i40e: Add support for HMC resource and profile for X722

Catherine Sullivan (1):
  i40e: Check client is open before calling client ops

Harshitha Ramamurthy (1):
  i40e: Initialize pointer in client_release function

Heinrich Schuchardt (1):
  i40e: use matching format identifiers

Jacob Keller (4):
  i40e: move i40e_vsi_config_rss below i40e_get_rss_aq
  i40e: fix broken i40e_config_rss_aq function
  i40e: use configured RSS key and lookup table in i40e_vsi_config_rss
  i40e: use alloc_workqueue instead of create_singlethread_workqueue

Jeff Kirsher (1):
  i40e/i40evf: Fix indentation

Joe Perches (1):
  i40e: Remove XSTRINGIFY macro definitions and uses

Mitch Williams (1):
  i40evf: report link speed

 drivers/net/ethernet/intel/i40e/i40e.h | 135 ++---
 drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h  |  59 ++---
 drivers/net/ethernet/intel/i40e/i40e_client.c  |  30 -
 drivers/net/ethernet/intel/i40e/i40e_client.h  |   6 +-
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c |  26 ++--
 drivers/net/ethernet/intel/i40e/i40e_main.c| 127 +--
 drivers/net/ethernet/intel/i40e/i40e_txrx.c|   6 +-
 .../net/ethernet/intel/i40evf/i40e_adminq_cmd.h|  59 ++---
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c  |   6 +-
 drivers/net/ethernet/intel/i40evf/i40evf.h |  58 -
 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c |  26 +++-
 drivers/net/ethernet/intel/i40evf/i40evf_main.c|   5 +-
 .../net/ethernet/intel/i40evf/i40evf_virtchnl.c|  55 +++--
 13 files changed, 367 insertions(+), 231 deletions(-)

-- 
2.7.4



[PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation

2016-08-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Aug 2016 07:50:09 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

  This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

Signed-off-by: Markus Elfring 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 6388bc0..bb89f04 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char 
__user *buf,
struct mlx5_core_dev *dev = filp->private_data;
struct mlx5_cmd_debug *dbg = >cmd.dbg;
void *ptr;
-   int err;
 
if (*pos != 0)
return -EINVAL;
@@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char 
__user *buf,
kfree(dbg->in_msg);
dbg->in_msg = NULL;
dbg->inlen = 0;
-
-   ptr = kzalloc(count, GFP_KERNEL);
-   if (!ptr)
-   return -ENOMEM;
-
-   if (copy_from_user(ptr, buf, count)) {
-   err = -EFAULT;
-   goto out;
-   }
+   ptr = memdup_user(buf, count);
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
dbg->in_msg = ptr;
dbg->inlen = count;
 
*pos = count;
 
return count;
-
-out:
-   kfree(ptr);
-   return err;
 }
 
 static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
-- 
2.9.3