[PATCH 1/1] mlx4_en: make mlx4_log_num_mgm_entry_size static

2017-07-02 Thread Zhu Yanjun
The variable mlx4_log_num_mgm_entry_size is only called in main.c.

CC: Joe Jin 
CC: Junxiao Bi 
Signed-off-by: Zhu Yanjun 
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 2 +-
 drivers/net/ethernet/mellanox/mlx4/mlx4.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 83aab1e..4b67277 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -91,7 +91,7 @@ module_param_array(probe_vf, byte, _vfs_argc, 0444);
 MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 
0)\n"
   "probe_vf=port1,port2,port1+2");
 
-int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE;
+static int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE;
 module_param_named(log_num_mgm_entry_size,
mlx4_log_num_mgm_entry_size, int, 0444);
 MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num"
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h 
b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index b4f1bc5..a3f5edb 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -231,7 +231,6 @@ do {
\
 #define mlx4_warn(mdev, format, ...)   \
dev_warn(&(mdev)->persist->pdev->dev, format, ##__VA_ARGS__)
 
-extern int mlx4_log_num_mgm_entry_size;
 extern int log_mtts_per_seg;
 extern int mlx4_internal_err_reset;
 
-- 
2.7.4



Re: linux-next: manual merge of the net-next tree with the pci tree

2017-07-02 Thread Stephen Rothwell
Hi all,

With the merge window opening, just a reminder that this conflict still
exists.

On Wed, 21 Jun 2017 11:54:43 +1000 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the net-next tree got a conflict in:
> 
>   drivers/net/wireless/marvell/mwifiex/pcie.c
> 
> between commit:
> 
>   c336cc0ee4eb ("PCI: Split ->reset_notify() method into ->reset_prepare() 
> and ->reset_done()")
> 
> from the pci tree and commit:
> 
>   68efd0386988 ("mwifiex: pcie: stop setting/clearing 'surprise_removed'")
> 
> from the net-next tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc drivers/net/wireless/marvell/mwifiex/pcie.c
> index 279adf124fc9,b53ecf1eddda..
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@@ -361,48 -359,35 +361,46 @@@ static void mwifiex_pcie_reset_prepare(
>   }
>   
>   mwifiex_dbg(adapter, INFO,
>  -"%s: vendor=0x%4.04x device=0x%4.04x rev=%d %s\n",
>  -__func__, pdev->vendor, pdev->device,
>  -pdev->revision,
>  -prepare ? "Pre-FLR" : "Post-FLR");
>  -
>  -if (prepare) {
>  -/* Kernel would be performing FLR after this notification.
>  - * Cleanup all software without cleaning anything related to
>  - * PCIe and HW.
>  - */
>  -mwifiex_shutdown_sw(adapter);
>  -clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, >work_flags);
>  -clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, >work_flags);
>  -} else {
>  -/* Kernel stores and restores PCIe function context before and
>  - * after performing FLR respectively. Reconfigure the software
>  - * and firmware including firmware redownload
>  - */
>  -ret = mwifiex_reinit_sw(adapter);
>  -if (ret) {
>  -dev_err(>dev, "reinit failed: %d\n", ret);
>  -return;
>  -}
>  -}
>  +"%s: vendor=0x%4.04x device=0x%4.04x rev=%d Pre-FLR\n",
>  +__func__, pdev->vendor, pdev->device, pdev->revision);
>  +
>  +mwifiex_shutdown_sw(adapter);
> - adapter->surprise_removed = true;
>  +clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, >work_flags);
>  +clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, >work_flags);
>   mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
>   }
>   
>  -static const struct pci_error_handlers mwifiex_pcie_err_handler[] = {
>  -{ .reset_notify = mwifiex_pcie_reset_notify, },
>  +/*
>  + * Kernel stores and restores PCIe function context before and after 
> performing
>  + * FLR respectively. Reconfigure the software and firmware including 
> firmware
>  + * redownload.
>  + */
>  +static void mwifiex_pcie_reset_done(struct pci_dev *pdev)
>  +{
>  +struct pcie_service_card *card = pci_get_drvdata(pdev);
>  +struct mwifiex_adapter *adapter = card->adapter;
>  +int ret;
>  +
>  +if (!adapter) {
>  +dev_err(>dev, "%s: adapter structure is not valid\n",
>  +__func__);
>  +return;
>  +}
>  +
>  +mwifiex_dbg(adapter, INFO,
>  +"%s: vendor=0x%4.04x device=0x%4.04x rev=%d Post-FLR\n",
>  +__func__, pdev->vendor, pdev->device, pdev->revision);
>  +
> - adapter->surprise_removed = false;
>  +ret = mwifiex_reinit_sw(adapter);
>  +if (ret)
>  +dev_err(>dev, "reinit failed: %d\n", ret);
>  +else
>  +mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
>  +}
>  +
>  +static const struct pci_error_handlers mwifiex_pcie_err_handler = {
>  +.reset_prepare  = mwifiex_pcie_reset_prepare,
>  +.reset_done = mwifiex_pcie_reset_done,
>   };
>   
>   #ifdef CONFIG_PM_SLEEP

-- 
Cheers,
Stephen Rothwell


linux-next: manual merge of the net-next tree with the net tree

2017-07-02 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got conflicts in:

  drivers/net/ethernet/mellanox/mlx5/core/health.c
  include/linux/mlx5/driver.h

between commit:

  2a0165a034ac ("net/mlx5: Cancel delayed recovery work when unloading the 
driver")

from the net tree and commit:

  0179720d6be2 ("Introduce new function for entering bad-health state.")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/net/ethernet/mellanox/mlx5/core/health.c
index 8a8b5f0e497c,0648a659b21d..
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@@ -193,8 -193,8 +194,8 @@@ static void health_care(struct work_str
mlx5_core_warn(dev, "handling bad device here\n");
mlx5_handle_bad_state(dev);
  
-   spin_lock(>wq_lock);
+   spin_lock_irqsave(>wq_lock, flags);
 -  if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, >flags))
 +  if (!test_bit(MLX5_DROP_NEW_RECOVERY_WORK, >flags))
schedule_delayed_work(>recover_work, recover_delay);
else
dev_err(>pdev->dev,
@@@ -334,11 -341,11 +343,12 @@@ void mlx5_stop_health_poll(struct mlx5_
  void mlx5_drain_health_wq(struct mlx5_core_dev *dev)
  {
struct mlx5_core_health *health = >priv.health;
+   unsigned long flags;
  
-   spin_lock(>wq_lock);
+   spin_lock_irqsave(>wq_lock, flags);
set_bit(MLX5_DROP_NEW_HEALTH_WORK, >flags);
 +  set_bit(MLX5_DROP_NEW_RECOVERY_WORK, >flags);
-   spin_unlock(>wq_lock);
+   spin_unlock_irqrestore(>wq_lock, flags);
cancel_delayed_work_sync(>recover_work);
cancel_work_sync(>work);
  }
diff --cc include/linux/mlx5/driver.h
index ba260330ce5e,2ab4ae3e3a1a..
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@@ -925,7 -945,7 +945,8 @@@ int mlx5_health_init(struct mlx5_core_d
  void mlx5_start_health_poll(struct mlx5_core_dev *dev);
  void mlx5_stop_health_poll(struct mlx5_core_dev *dev);
  void mlx5_drain_health_wq(struct mlx5_core_dev *dev);
 +void mlx5_drain_health_recovery(struct mlx5_core_dev *dev);
+ void mlx5_trigger_health_work(struct mlx5_core_dev *dev);
  int mlx5_buf_alloc_node(struct mlx5_core_dev *dev, int size,
struct mlx5_buf *buf, int node);
  int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, struct mlx5_buf *buf);


linux-next: manual merge of the net-next tree with the arm64 tree

2017-07-02 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  arch/arm64/net/bpf_jit_comp.c

between commit:

  425e1ed73e65 ("arm64: fix endianness annotation for 'struct jit_ctx' and 
friends")

from the arm64 tree and commit:

  f1c9eed7f437 ("bpf, arm64: take advantage of stack_depth tracking")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/arm64/net/bpf_jit_comp.c
index 8860bb9c33a1,2f0505b5c240..
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@@ -70,7 -70,8 +70,8 @@@ struct jit_ctx 
int idx;
int epilogue_offset;
int *offset;
 -  u32 *image;
 +  __le32 *image;
+   u32 stack_size;
  };
  
  static inline void emit(const u32 insn, struct jit_ctx *ctx)


[PATCH] net: core: Fix slab-out-of-bounds in netdev_stats_to_stats64

2017-07-02 Thread Alban Browaeys
commit 9256645af098 ("net/core: relax BUILD_BUG_ON in
netdev_stats_to_stats64") made an attempt to read beyond
the size of the source a possibility.

Fix to only copy src size to dest. As dest might be bigger than src.

 ==
 BUG: KASAN: slab-out-of-bounds in netdev_stats_to_stats64+0xe/0x30 at addr 
8801be248b20
 Read of size 192 by task VBoxNetAdpCtl/6734
 CPU: 1 PID: 6734 Comm: VBoxNetAdpCtl Tainted: G   O
4.11.4prahal+intel+ #118
 Hardware name: LENOVO 20CDCTO1WW/20CDCTO1WW, BIOS GQET52WW (1.32 ) 05/04/2017
 Call Trace:
  dump_stack+0x63/0x86
  kasan_object_err+0x1c/0x70
  kasan_report+0x270/0x520
  ? netdev_stats_to_stats64+0xe/0x30
  ? sched_clock_cpu+0x1b/0x190
  ? __module_address+0x3e/0x3b0
  ? unwind_next_frame+0x1ea/0xb00
  check_memory_region+0x13c/0x1a0
  memcpy+0x23/0x50
  netdev_stats_to_stats64+0xe/0x30
  dev_get_stats+0x1b9/0x230
  rtnl_fill_stats+0x44/0xc00
  ? nla_put+0xc6/0x130
  rtnl_fill_ifinfo+0xe9e/0x3700
  ? rtnl_fill_vfinfo+0xde0/0xde0
  ? sched_clock+0x9/0x10
  ? sched_clock+0x9/0x10
  ? sched_clock_local+0x120/0x130
  ? __module_address+0x3e/0x3b0
  ? unwind_next_frame+0x1ea/0xb00
  ? sched_clock+0x9/0x10
  ? sched_clock+0x9/0x10
  ? sched_clock_cpu+0x1b/0x190
  ? VBoxNetAdpLinuxIOCtlUnlocked+0x14b/0x280 [vboxnetadp]
  ? depot_save_stack+0x1d8/0x4a0
  ? depot_save_stack+0x34f/0x4a0
  ? depot_save_stack+0x34f/0x4a0
  ? save_stack+0xb1/0xd0
  ? save_stack_trace+0x16/0x20
  ? save_stack+0x46/0xd0
  ? kasan_slab_alloc+0x12/0x20
  ? __kmalloc_node_track_caller+0x10d/0x350
  ? __kmalloc_reserve.isra.36+0x2c/0xc0
  ? __alloc_skb+0xd0/0x560
  ? rtmsg_ifinfo_build_skb+0x61/0x120
  ? rtmsg_ifinfo.part.25+0x16/0xb0
  ? rtmsg_ifinfo+0x47/0x70
  ? register_netdev+0x15/0x30
  ? vboxNetAdpOsCreate+0xc0/0x1c0 [vboxnetadp]
  ? vboxNetAdpCreate+0x210/0x400 [vboxnetadp]
  ? VBoxNetAdpLinuxIOCtlUnlocked+0x14b/0x280 [vboxnetadp]
  ? do_vfs_ioctl+0x17f/0xff0
  ? SyS_ioctl+0x74/0x80
  ? do_syscall_64+0x182/0x390
  ? __alloc_skb+0xd0/0x560
  ? __alloc_skb+0xd0/0x560
  ? save_stack_trace+0x16/0x20
  ? init_object+0x64/0xa0
  ? ___slab_alloc+0x1ae/0x5c0
  ? ___slab_alloc+0x1ae/0x5c0
  ? __alloc_skb+0xd0/0x560
  ? sched_clock+0x9/0x10
  ? kasan_unpoison_shadow+0x35/0x50
  ? kasan_kmalloc+0xad/0xe0
  ? __kmalloc_node_track_caller+0x246/0x350
  ? __alloc_skb+0xd0/0x560
  ? kasan_unpoison_shadow+0x35/0x50
  ? memset+0x31/0x40
  ? __alloc_skb+0x31f/0x560
  ? napi_consume_skb+0x320/0x320
  ? br_get_link_af_size_filtered+0xb7/0x120 [bridge]
  ? if_nlmsg_size+0x440/0x630
  rtmsg_ifinfo_build_skb+0x83/0x120
  rtmsg_ifinfo.part.25+0x16/0xb0
  rtmsg_ifinfo+0x47/0x70
  register_netdevice+0xa2b/0xe50
  ? __kmalloc+0x171/0x2d0
  ? netdev_change_features+0x80/0x80
  register_netdev+0x15/0x30
  vboxNetAdpOsCreate+0xc0/0x1c0 [vboxnetadp]
  vboxNetAdpCreate+0x210/0x400 [vboxnetadp]
  ? vboxNetAdpComposeMACAddress+0x1d0/0x1d0 [vboxnetadp]
  ? kasan_check_write+0x14/0x20
  VBoxNetAdpLinuxIOCtlUnlocked+0x14b/0x280 [vboxnetadp]
  ? VBoxNetAdpLinuxOpen+0x20/0x20 [vboxnetadp]
  ? lock_acquire+0x11c/0x270
  ? __audit_syscall_entry+0x2fb/0x660
  do_vfs_ioctl+0x17f/0xff0
  ? __audit_syscall_entry+0x2fb/0x660
  ? ioctl_preallocate+0x1d0/0x1d0
  ? __audit_syscall_entry+0x2fb/0x660
  ? kmem_cache_free+0xb2/0x250
  ? syscall_trace_enter+0x537/0xd00
  ? exit_to_usermode_loop+0x100/0x100
  SyS_ioctl+0x74/0x80
  ? do_sys_open+0x350/0x350
  ? do_vfs_ioctl+0xff0/0xff0
  do_syscall_64+0x182/0x390
  entry_SYSCALL64_slow_path+0x25/0x25
 RIP: 0033:0x7f7e39a1ae07
 RSP: 002b:7ffc6f04c6d8 EFLAGS: 0206 ORIG_RAX: 0010
 RAX: ffda RBX: 7ffc6f04c730 RCX: 7f7e39a1ae07
 RDX: 7ffc6f04c730 RSI: c0207601 RDI: 0007
 RBP: 7ffc6f04c700 R08: 7ffc6f04c780 R09: 0008
 R10: 0541 R11: 0206 R12: 0007
 R13: c0207601 R14: 7ffc6f04c730 R15: 0012
 Object at 8801be248008, in cache kmalloc-4096 size: 4096
 Allocated:
 PID = 6734
  save_stack_trace+0x16/0x20
  save_stack+0x46/0xd0
  kasan_kmalloc+0xad/0xe0
  __kmalloc+0x171/0x2d0
  alloc_netdev_mqs+0x8a7/0xbe0
  vboxNetAdpOsCreate+0x65/0x1c0 [vboxnetadp]
  vboxNetAdpCreate+0x210/0x400 [vboxnetadp]
  VBoxNetAdpLinuxIOCtlUnlocked+0x14b/0x280 [vboxnetadp]
  do_vfs_ioctl+0x17f/0xff0
  SyS_ioctl+0x74/0x80
  do_syscall_64+0x182/0x390
  return_from_SYSCALL_64+0x0/0x6a
 Freed:
 PID = 5600
  save_stack_trace+0x16/0x20
  save_stack+0x46/0xd0
  kasan_slab_free+0x73/0xc0
  kfree+0xe4/0x220
  kvfree+0x25/0x30
  single_release+0x74/0xb0
  __fput+0x265/0x6b0
  fput+0x9/0x10
  task_work_run+0xd5/0x150
  exit_to_usermode_loop+0xe2/0x100
  do_syscall_64+0x26c/0x390
  return_from_SYSCALL_64+0x0/0x6a
 Memory state around the buggy address:
  8801be248a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  8801be248b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 >8801be248b80: 00 00 00 00 00 00 00 

Re: [PATCH net-next] bpf: fix to bpf_setsockops

2017-07-02 Thread David Miller
From: Lawrence Brakmo 
Date: Sun, 2 Jul 2017 09:14:28 -0700

> Fixed build error due to misplaced "#ifdef CONFIG_INET" (moved 1
> statement up).
> 
> Signed-off-by: Lawrence Brakmo 

Applied, thank you.


[PATCH] netxen_nic: Remove unused pointer hdr in netxen_setup_minidump()

2017-07-02 Thread Christos Gkekas
Pointer hdr in netxen_setup_minidump() is set but never used, thus
should be removed.

Signed-off-by: Christos Gkekas 
---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c 
b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index e306765..6cec2a6 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -174,7 +174,6 @@ netxen_setup_minidump(struct netxen_adapter *adapter)
 {
int err = 0, i;
u32 *template, *tmp_buf;
-   struct netxen_minidump_template_hdr *hdr;
err = netxen_get_minidump_template_size(adapter);
if (err) {
adapter->mdump.fw_supports_md = 0;
@@ -218,8 +217,6 @@ netxen_setup_minidump(struct netxen_adapter *adapter)
template = (u32 *) adapter->mdump.md_template;
for (i = 0; i < adapter->mdump.md_template_size/sizeof(u32); i++)
*template++ = __le32_to_cpu(*tmp_buf++);
-   hdr = (struct netxen_minidump_template_hdr *)
-   adapter->mdump.md_template;
adapter->mdump.md_capture_buff = NULL;
adapter->mdump.fw_supports_md = 1;
adapter->mdump.md_enabled = 0;
-- 
2.7.4



Re: [PATCH] of_mdio: Fix broken PHY IRQ in case of probe deferral

2017-07-02 Thread Geert Uytterhoeven
On Tue, Jun 6, 2017 at 11:43 AM, Geert Uytterhoeven
 wrote:
> On Tue, May 23, 2017 at 11:36 AM, Geert Uytterhoeven
>  wrote:
>> On Fri, May 19, 2017 at 12:21 AM, Florian Fainelli  
>> wrote:
>>> On 05/18/2017 01:36 PM, Geert Uytterhoeven wrote:
 On Thu, May 18, 2017 at 9:34 PM, Andrew Lunn  wrote:
>>> This most certainly works fine in the simple case where you have one PHY
>>> hanging off the MDIO bus, now what happens if you have several?
>>>
>>> Presumably, the first PHY that returns EPROBE_DEFER will make the entire
>>> bus registration return EPROB_DEFER as well, and so on, and so forth,
>>> but I am not sure if we will be properly unwinding the successful
>>> registration of PHYs that either don't have an interrupt, or did not
>>> return EPROBE_DEFER.
>>>
>>> It should be possible to mimic this behavior by using the fixed PHY, and
>>> possibly the dsa_loop.c driver which would create 4 ports, expecting 4
>>> fixed PHYs to be present.
>>
>> mdiobus_unregister(), called from of_mdiobus_register() on failure,
>> should do the unwinding, right?
>>
>> And when the driver is reprobed, all PHYs are reprobed, until they all
>> succeed.
>
> That is the theory. I looked at that while reviewing the patch. But
> this has probably not been tested in anger. It would be good to test
> this properly, with not just the first PHY returning -EPROBE_DEFER, to
> really test the unwind.

 Unfortunately I don't have a board with multiple PHYs, so I cannot test
 that case.
>>
>> I tried adding a few dummy PHYs in DT, but that didn't work.
>>
>> So how can we proceed?
>>
>> I think the only way my patch can cause issues is because some systems
>> may rely on EPROBE_DEFER errors being ignored.
>>
 Does unbinding/rebinding a network driver with multiple PHYs currently
 work? Or module unload/reload?
>>>
>>> Usually there is a strict 1:1 mapping between a network device (not
>>> driver) and a PHY device, switch drivers however, would have multiple
>>> PHYs (one per port, aka net_deice).
>>>
>>> NB: binding and unbinding of PHYs is pretty broken at the moment though,
>>> because there is a complete disconnect between what the Ethernet MAC
>>> expects, and the state in which the PHY is. I had some patches to fix
>>> that, but this turned out to be playing whack-a-mole which I typically
>>> suck at.
>>
>> I didn't mean unbinding the PHY, but the network device.
>> Don't you have the same issue with the state of PHYs as left by the 
>> bootloader?
>
> Anyone who can test the behavior on an Ethernet device with multiple PHYs,
> e.g. by faking an -EPROBE_DEFER somewhere in the middle?
>
> I'd like to get this issue fixed in v4.13, to avoid a regression when 
> migrating
> several systems to a new and better clock driver in v4.14, which will trigger
> EPROBE_DEFER.

Ping?

This patch fixes a real issue.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH net-next v5 07/16] bpf: Add setsockopt helper function to bpf

2017-07-02 Thread Lawrence Brakmo

On 7/1/17, 11:51 PM, "kbuild test robot"  wrote:

Hi Lawrence,

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Lawrence-Brakmo/bpf-Adding-support-for-sock_ops/20170701-203039
config: x86_64-randconfig-i0-07010430 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `bpf_setsockopt':
>> (.text+0x5bb69): undefined reference to `tcp_setsockopt'

Patch “bpf: fix to bpf_setsockops” submitted.

---
0-DAY kernel test infrastructureOpen Source Technology 
Center

https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.01.org_pipermail_kbuild-2Dall=DwIBAg=5VD0RTtNlTh3ycd41b3MUw=pq_Mqvzfy-C8ltkgyx1u_g=dZ7FxbjgoGHxAmv2wftPr-yQVE8DrO3ebEExzi3pJYA=Z1-P-WmB8WW1PW8vGJLtp_UKUBbgS9R6ZQD8p0du3Xo=
Intel Corporation




Re: [PATCH net 1/2] vxlan: fix hlist corruption

2017-07-02 Thread Waiman Long
On 07/02/2017 01:00 PM, Jiri Benc wrote:
> It's not a good idea to add the same hlist_node to two different hash lists.
> This leads to various hard to debug memory corruptions.
>
> Fixes: b1be00a6c39f ("vxlan: support both IPv4 and IPv6 sockets in a single 
> vxlan device")
> Signed-off-by: Jiri Benc 
> ---
>  drivers/net/vxlan.c | 30 --
>  include/net/vxlan.h | 10 +-
>  2 files changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index 5fa798a5c9a6..c4e540126258 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -228,15 +228,15 @@ static struct vxlan_sock *vxlan_find_sock(struct net 
> *net, sa_family_t family,
>  
>  static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, __be32 vni)
>  {
> - struct vxlan_dev *vxlan;
> + struct vxlan_dev_node *node;
>  
>   /* For flow based devices, map all packets to VNI 0 */
>   if (vs->flags & VXLAN_F_COLLECT_METADATA)
>   vni = 0;
>  
> - hlist_for_each_entry_rcu(vxlan, vni_head(vs, vni), hlist) {
> - if (vxlan->default_dst.remote_vni == vni)
> - return vxlan;
> + hlist_for_each_entry_rcu(node, vni_head(vs, vni), hlist) {
> + if (node->vxlan->default_dst.remote_vni == vni)
> + return node->vxlan;
>   }
>  
>   return NULL;
> @@ -2365,17 +2365,22 @@ static void vxlan_vs_del_dev(struct vxlan_dev *vxlan)
>   struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
>  
>   spin_lock(>sock_lock);
> - hlist_del_init_rcu(>hlist);
> + hlist_del_init_rcu(>hlist4.hlist);
> +#if IS_ENABLED(CONFIG_IPV6)
> + hlist_del_init_rcu(>hlist6.hlist);
> +#endif
>   spin_unlock(>sock_lock);
>  }
>  
> -static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan)
> +static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan,
> +  struct vxlan_dev_node *node)
>  {
>   struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
>   __be32 vni = vxlan->default_dst.remote_vni;
>  
> + node->vxlan = vxlan;
>   spin_lock(>sock_lock);
> - hlist_add_head_rcu(>hlist, vni_head(vs, vni));
> + hlist_add_head_rcu(>hlist, vni_head(vs, vni));
>   spin_unlock(>sock_lock);
>  }
>  
> @@ -2819,6 +2824,7 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, 
> bool ipv6)
>  {
>   struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
>   struct vxlan_sock *vs = NULL;
> + struct vxlan_dev_node *node;
>  
>   if (!vxlan->cfg.no_share) {
>   spin_lock(>sock_lock);
> @@ -2836,12 +2842,16 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, 
> bool ipv6)
>   if (IS_ERR(vs))
>   return PTR_ERR(vs);
>  #if IS_ENABLED(CONFIG_IPV6)
> - if (ipv6)
> + if (ipv6) {
>   rcu_assign_pointer(vxlan->vn6_sock, vs);
> - else
> + node = >hlist6;
> + } else
>  #endif
> + {
>   rcu_assign_pointer(vxlan->vn4_sock, vs);
> - vxlan_vs_add_dev(vs, vxlan);
> + node = >hlist4;
> + }
> + vxlan_vs_add_dev(vs, vxlan, node);
>   return 0;
>  }
>  
> diff --git a/include/net/vxlan.h b/include/net/vxlan.h
> index 49a59202f85e..da7d6b89df77 100644
> --- a/include/net/vxlan.h
> +++ b/include/net/vxlan.h
> @@ -221,9 +221,17 @@ struct vxlan_config {
>   boolno_share;
>  };
>  
> +struct vxlan_dev_node {
> + struct hlist_node hlist;
> + struct vxlan_dev *vxlan;
> +};
> +
>  /* Pseudo network device */
>  struct vxlan_dev {
> - struct hlist_node hlist;/* vni hash table */
> + struct vxlan_dev_node hlist4;   /* vni hash table for IPv4 socket */
> +#if IS_ENABLED(CONFIG_IPV6)
> + struct vxlan_dev_node hlist6;   /* vni hash table for IPv6 socket */
> +#endif
>   struct list_head  next; /* vxlan's per namespace list */
>   struct vxlan_sock __rcu *vn4_sock;  /* listening socket for IPv4 */
>  #if IS_ENABLED(CONFIG_IPV6)

I didn't see any init code for hlist4 and hlist6. Is vxlan_dev going to
be *zalloc'ed so that they are guaranteed to be NULL? If not, you may
need to add  init code as not both hlists will be hashed and so one of
them may contain invalid data.

-Longman



[PATCH net 2/2] geneve: fix hlist corruption

2017-07-02 Thread Jiri Benc
It's not a good idea to add the same hlist_node to two different hash lists.
This leads to various hard to debug memory corruptions.

Fixes: 8ed66f0e8235 ("geneve: implement support for IPv6-based tunnels")
Cc: John W. Linville 
Signed-off-by: Jiri Benc 
---
 drivers/net/geneve.c | 48 
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 199459bd6961..6ec8fc9aad8f 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -45,9 +45,17 @@ struct geneve_net {
 
 static unsigned int geneve_net_id;
 
+struct geneve_dev_node {
+   struct hlist_node hlist;
+   struct geneve_dev *geneve;
+};
+
 /* Pseudo network device */
 struct geneve_dev {
-   struct hlist_node  hlist;   /* vni hash table */
+   struct geneve_dev_node hlist4;  /* vni hash table for IPv4 socket */
+#if IS_ENABLED(CONFIG_IPV6)
+   struct geneve_dev_node hlist6;  /* vni hash table for IPv6 socket */
+#endif
struct net *net;/* netns for packet i/o */
struct net_device  *dev;/* netdev for geneve tunnel */
struct ip_tunnel_info info;
@@ -123,16 +131,16 @@ static struct geneve_dev *geneve_lookup(struct 
geneve_sock *gs,
__be32 addr, u8 vni[])
 {
struct hlist_head *vni_list_head;
-   struct geneve_dev *geneve;
+   struct geneve_dev_node *node;
__u32 hash;
 
/* Find the device for this VNI */
hash = geneve_net_vni_hash(vni);
vni_list_head = >vni_list[hash];
-   hlist_for_each_entry_rcu(geneve, vni_list_head, hlist) {
-   if (eq_tun_id_and_vni((u8 *)>info.key.tun_id, vni) &&
-   addr == geneve->info.key.u.ipv4.dst)
-   return geneve;
+   hlist_for_each_entry_rcu(node, vni_list_head, hlist) {
+   if (eq_tun_id_and_vni((u8 *)>geneve->info.key.tun_id, 
vni) &&
+   addr == node->geneve->info.key.u.ipv4.dst)
+   return node->geneve;
}
return NULL;
 }
@@ -142,16 +150,16 @@ static struct geneve_dev *geneve6_lookup(struct 
geneve_sock *gs,
 struct in6_addr addr6, u8 vni[])
 {
struct hlist_head *vni_list_head;
-   struct geneve_dev *geneve;
+   struct geneve_dev_node *node;
__u32 hash;
 
/* Find the device for this VNI */
hash = geneve_net_vni_hash(vni);
vni_list_head = >vni_list[hash];
-   hlist_for_each_entry_rcu(geneve, vni_list_head, hlist) {
-   if (eq_tun_id_and_vni((u8 *)>info.key.tun_id, vni) &&
-   ipv6_addr_equal(, >info.key.u.ipv6.dst))
-   return geneve;
+   hlist_for_each_entry_rcu(node, vni_list_head, hlist) {
+   if (eq_tun_id_and_vni((u8 *)>geneve->info.key.tun_id, 
vni) &&
+   ipv6_addr_equal(, >geneve->info.key.u.ipv6.dst))
+   return node->geneve;
}
return NULL;
 }
@@ -579,6 +587,7 @@ static int geneve_sock_add(struct geneve_dev *geneve, bool 
ipv6)
 {
struct net *net = geneve->net;
struct geneve_net *gn = net_generic(net, geneve_net_id);
+   struct geneve_dev_node *node;
struct geneve_sock *gs;
__u8 vni[3];
__u32 hash;
@@ -597,15 +606,20 @@ static int geneve_sock_add(struct geneve_dev *geneve, 
bool ipv6)
 out:
gs->collect_md = geneve->collect_md;
 #if IS_ENABLED(CONFIG_IPV6)
-   if (ipv6)
+   if (ipv6) {
rcu_assign_pointer(geneve->sock6, gs);
-   else
+   node = >hlist6;
+   } else
 #endif
+   {
rcu_assign_pointer(geneve->sock4, gs);
+   node = >hlist4;
+   }
+   node->geneve = geneve;
 
tunnel_id_to_vni(geneve->info.key.tun_id, vni);
hash = geneve_net_vni_hash(vni);
-   hlist_add_head_rcu(>hlist, >vni_list[hash]);
+   hlist_add_head_rcu(>hlist, >vni_list[hash]);
return 0;
 }
 
@@ -632,8 +646,10 @@ static int geneve_stop(struct net_device *dev)
 {
struct geneve_dev *geneve = netdev_priv(dev);
 
-   if (!hlist_unhashed(>hlist))
-   hlist_del_rcu(>hlist);
+   hlist_del_init_rcu(>hlist4.hlist);
+#if IS_ENABLED(CONFIG_IPV6)
+   hlist_del_init_rcu(>hlist6.hlist);
+#endif
geneve_sock_release(geneve);
return 0;
 }
-- 
1.8.3.1



[PATCH net 1/2] vxlan: fix hlist corruption

2017-07-02 Thread Jiri Benc
It's not a good idea to add the same hlist_node to two different hash lists.
This leads to various hard to debug memory corruptions.

Fixes: b1be00a6c39f ("vxlan: support both IPv4 and IPv6 sockets in a single 
vxlan device")
Signed-off-by: Jiri Benc 
---
 drivers/net/vxlan.c | 30 --
 include/net/vxlan.h | 10 +-
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 5fa798a5c9a6..c4e540126258 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -228,15 +228,15 @@ static struct vxlan_sock *vxlan_find_sock(struct net 
*net, sa_family_t family,
 
 static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, __be32 vni)
 {
-   struct vxlan_dev *vxlan;
+   struct vxlan_dev_node *node;
 
/* For flow based devices, map all packets to VNI 0 */
if (vs->flags & VXLAN_F_COLLECT_METADATA)
vni = 0;
 
-   hlist_for_each_entry_rcu(vxlan, vni_head(vs, vni), hlist) {
-   if (vxlan->default_dst.remote_vni == vni)
-   return vxlan;
+   hlist_for_each_entry_rcu(node, vni_head(vs, vni), hlist) {
+   if (node->vxlan->default_dst.remote_vni == vni)
+   return node->vxlan;
}
 
return NULL;
@@ -2365,17 +2365,22 @@ static void vxlan_vs_del_dev(struct vxlan_dev *vxlan)
struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
 
spin_lock(>sock_lock);
-   hlist_del_init_rcu(>hlist);
+   hlist_del_init_rcu(>hlist4.hlist);
+#if IS_ENABLED(CONFIG_IPV6)
+   hlist_del_init_rcu(>hlist6.hlist);
+#endif
spin_unlock(>sock_lock);
 }
 
-static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan)
+static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan,
+struct vxlan_dev_node *node)
 {
struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
__be32 vni = vxlan->default_dst.remote_vni;
 
+   node->vxlan = vxlan;
spin_lock(>sock_lock);
-   hlist_add_head_rcu(>hlist, vni_head(vs, vni));
+   hlist_add_head_rcu(>hlist, vni_head(vs, vni));
spin_unlock(>sock_lock);
 }
 
@@ -2819,6 +2824,7 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool 
ipv6)
 {
struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
struct vxlan_sock *vs = NULL;
+   struct vxlan_dev_node *node;
 
if (!vxlan->cfg.no_share) {
spin_lock(>sock_lock);
@@ -2836,12 +2842,16 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, 
bool ipv6)
if (IS_ERR(vs))
return PTR_ERR(vs);
 #if IS_ENABLED(CONFIG_IPV6)
-   if (ipv6)
+   if (ipv6) {
rcu_assign_pointer(vxlan->vn6_sock, vs);
-   else
+   node = >hlist6;
+   } else
 #endif
+   {
rcu_assign_pointer(vxlan->vn4_sock, vs);
-   vxlan_vs_add_dev(vs, vxlan);
+   node = >hlist4;
+   }
+   vxlan_vs_add_dev(vs, vxlan, node);
return 0;
 }
 
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 49a59202f85e..da7d6b89df77 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -221,9 +221,17 @@ struct vxlan_config {
boolno_share;
 };
 
+struct vxlan_dev_node {
+   struct hlist_node hlist;
+   struct vxlan_dev *vxlan;
+};
+
 /* Pseudo network device */
 struct vxlan_dev {
-   struct hlist_node hlist;/* vni hash table */
+   struct vxlan_dev_node hlist4;   /* vni hash table for IPv4 socket */
+#if IS_ENABLED(CONFIG_IPV6)
+   struct vxlan_dev_node hlist6;   /* vni hash table for IPv6 socket */
+#endif
struct list_head  next; /* vxlan's per namespace list */
struct vxlan_sock __rcu *vn4_sock;  /* listening socket for IPv4 */
 #if IS_ENABLED(CONFIG_IPV6)
-- 
1.8.3.1



[PATCH net 0/2] vxlan, geneve: fix hlist corruption

2017-07-02 Thread Jiri Benc
Fix memory corruption introduced with the support of both IPv4 and IPv6
sockets in a single device. The same bug is present in VXLAN and Geneve.

Signed-off-by: Jiri Benc 


Jiri Benc (2):
  vxlan: fix hlist corruption
  geneve: fix hlist corruption

 drivers/net/geneve.c | 48 
 drivers/net/vxlan.c  | 30 --
 include/net/vxlan.h  | 10 +-
 3 files changed, 61 insertions(+), 27 deletions(-)

-- 
1.8.3.1



[PATCH net-next] bpf: fix to bpf_setsockops

2017-07-02 Thread Lawrence Brakmo
Fixed build error due to misplaced "#ifdef CONFIG_INET" (moved 1
statement up).

Signed-off-by: Lawrence Brakmo 
---
 net/core/filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 523b91d..e5c280a 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2717,9 +2717,9 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, 
bpf_sock,
default:
ret = -EINVAL;
}
+#ifdef CONFIG_INET
} else if (level == SOL_TCP &&
   sk->sk_prot->setsockopt == tcp_setsockopt) {
-#ifdef CONFIG_INET
if (optname == TCP_CONGESTION) {
char name[TCP_CA_NAME_MAX];
 
@@ -2757,7 +2757,6 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, 
bpf_sock,
ret = -EINVAL;
}
}
-#else
ret = -EINVAL;
 #endif
} else {
-- 
2.9.3



[PATCH net-next] net/mlxfw: Properly handle dependancy with non-loadable mlx5

2017-07-02 Thread Or Gerlitz
If mlx5 is set to be built-in and mlxfw as a module, we
get a link error:

drivers/built-in.o: In function `mlx5_firmware_flash':
(.text+0x5aed72): undefined reference to `mlxfw_firmware_flash'

Since we don't want to mandate selecting mlxfw for mlx5 users, we
use the IS_REACHABLE macro to make sure that a stub is exposed
to the caller.

Signed-off-by: Or Gerlitz 
Reported-by: Jakub Kicinski 
Reported-by: Arnd Bergmann 
---
 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h 
b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
index 9ca8538..7a712b6 100644
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
@@ -96,7 +96,7 @@ struct mlxfw_dev {
u16 psid_size;
 };
 
-#if IS_ENABLED(CONFIG_MLXFW)
+#if IS_REACHABLE(CONFIG_MLXFW)
 int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
 const struct firmware *firmware);
 #else
-- 
2.3.7



[PATCH 0/6] net: stmmac: revert "support future possible different internal phy mode"

2017-07-02 Thread Corentin Labbe
Hello

The current way to find if the phy is internal is to compare DT phy-mode
and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the
same phy mode than the internal one.

My first idea was to use phy-mode = "internal" but since internal phy-mode
is reserved for non-xMII protocol we cannot use it with dwmac-sun8i

I will send an additionnal patch for documenting more phy-mode = "internal"

Corentin Labbe (6):
  arm: sun8i: nanopi-neo: revert use internal phy-mode
  arm: sun8i: orangepi-2: revert "use internal phy-mode"
  arm: sun8i: orangepi-one: revert "use internal phy-mode"
  arm: sun8i: orangepi-zero: revert "use internal phy-mode"
  arm: sun8i: orangepipc: revert "use internal phy-mode"
  net: stmmac: revert "support future possible different internal phy
mode"

 arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts |  2 +-
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts |  2 +-
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts |  2 +-
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts   |  2 +-
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts|  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 10 +++---
 6 files changed, 8 insertions(+), 12 deletions(-)

-- 
2.13.0



[PATCH 5/6] arm: sun8i: orangepipc: revert "use internal phy-mode"

2017-07-02 Thread Corentin Labbe
Since internal phy-mode is reserved for non-xMII protocol we cannot use
it with dwmac-sun8i
This reverts commit 3432a86e641c ("arm: sun8i: orangepipc: use internal 
phy-mode")

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts 
b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
index 94edeb889e55..f5f0f15a2088 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
@@ -120,7 +120,7 @@
 
  {
phy-handle = <_mii_phy>;
-   phy-mode = "internal";
+   phy-mode = "mii";
allwinner,leds-active-low;
status = "okay";
 };
-- 
2.13.0



[PATCH 2/6] arm: sun8i: orangepi-2: revert "use internal phy-mode"

2017-07-02 Thread Corentin Labbe
Since internal phy-mode is reserved for non-xMII protocol we cannot use
it with dwmac-sun8i
This reverts commit 5a79b4f2a5e7 ("arm: sun8i: orangepi-2: use internal 
phy-mode")

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts 
b/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts
index a2a2b11dfeed..17cdeae19c6f 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts
@@ -120,7 +120,7 @@
 
  {
phy-handle = <_mii_phy>;
-   phy-mode = "internal";
+   phy-mode = "mii";
allwinner,leds-active-low;
status = "okay";
 };
-- 
2.13.0



[PATCH 1/6] arm: sun8i: nanopi-neo: revert use internal phy-mode

2017-07-02 Thread Corentin Labbe
Since internal phy-mode is reserved for non-xMII protocol we cannot use
it with dwmac-sun8i
This reverts commit bdcc005beac9 ("arm: sun8i: nanopi-neo: use internal 
phy-mode")

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts 
b/arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts
index 5c5ba806e2f1..78f6c24952dd 100644
--- a/arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts
+++ b/arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts
@@ -49,7 +49,7 @@
 
  {
phy-handle = <_mii_phy>;
-   phy-mode = "internal";
+   phy-mode = "mii";
allwinner,leds-active-low;
status = "okay";
 };
-- 
2.13.0



[PATCH 4/6] arm: sun8i: orangepi-zero: revert "use internal phy-mode"

2017-07-02 Thread Corentin Labbe
Since internal phy-mode is reserved for non-xMII protocol we cannot use
it with dwmac-sun8i
This reverts commit 6066de6848d4 ("arm: sun8i: orangepi-zero: use internal 
phy-mode")

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts 
b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
index 7c154b845baa..6713d0f2b3f4 100644
--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
@@ -106,7 +106,7 @@
 
  {
phy-handle = <_mii_phy>;
-   phy-mode = "internal";
+   phy-mode = "mii";
allwinner,leds-active-low;
status = "okay";
 };
-- 
2.13.0



[PATCH 6/6] net: stmmac: revert "support future possible different internal phy mode"

2017-07-02 Thread Corentin Labbe
Since internal phy-mode is reserved for non-xMII protocol we cannot use
it with dwmac-sun8i
This reverts commit 1c2fa5f84683 ("net: stmmac: support future possible 
different internal phy mode")

Signed-off-by: Corentin Labbe 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 6c2d1da05588..fffd6d5fc907 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -638,7 +638,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
 {
struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
struct device_node *node = priv->device->of_node;
-   int ret, phy_interface;
+   int ret;
u32 reg, val;
 
regmap_read(gmac->regmap, SYSCON_EMAC_REG, );
@@ -718,11 +718,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
if (gmac->variant->support_rmii)
reg &= ~SYSCON_RMII_EN;
 
-   phy_interface = priv->plat->interface;
-   /* if PHY is internal, select the mode (xMII) used by the SoC */
-   if (gmac->use_internal_phy)
-   phy_interface = gmac->variant->internal_phy;
-   switch (phy_interface) {
+   switch (priv->plat->interface) {
case PHY_INTERFACE_MODE_MII:
/* default */
break;
@@ -936,7 +932,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
}
 
plat_dat->interface = of_get_phy_mode(dev->of_node);
-   if (plat_dat->interface == PHY_INTERFACE_MODE_INTERNAL) {
+   if (plat_dat->interface == gmac->variant->internal_phy) {
dev_info(>dev, "Will use internal PHY\n");
gmac->use_internal_phy = true;
gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);
-- 
2.13.0



[PATCH 3/6] arm: sun8i: orangepi-one: revert "use internal phy-mode"

2017-07-02 Thread Corentin Labbe
Since internal phy-mode is reserved for non-xMII protocol we cannot use
it with dwmac-sun8i
This reverts commit 4ac57180eab2 ("arm: sun8i: orangepi-one: use internal 
phy-mode")

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts 
b/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
index 27e7ef4e42f2..6880268e8b87 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
@@ -100,7 +100,7 @@
 
  {
phy-handle = <_mii_phy>;
-   phy-mode = "internal";
+   phy-mode = "mii";
allwinner,leds-active-low;
status = "okay";
 };
-- 
2.13.0



Re: [PATCH] net: axienet: add of_phy_connect call for XAE_PHY_TYPE_MII case

2017-07-02 Thread Alvaro Gamez Machado
On Fri, Jun 30, 2017 at 10:30:38AM -0700, Florian Fainelli wrote:
> On 06/30/2017 02:25 AM, Alvaro Gamez Machado wrote:
> > if (lp->phy_node) {
> > -   if (lp->phy_type == XAE_PHY_TYPE_GMII) {
> > +   if (lp->phy_type == XAE_PHY_TYPE_MII) {
> > +   phydev = of_phy_connect(lp->ndev, lp->phy_node,
> > +   axienet_adjust_link, 0,
> > +   PHY_INTERFACE_MODE_MII);
> > +   } else if (lp->phy_type == XAE_PHY_TYPE_GMII) {
> > phydev = of_phy_connect(lp->ndev, lp->phy_node,
> > axienet_adjust_link, 0,
> > PHY_INTERFACE_MODE_GMII);
> 
> Seems like this could be simplified even further if the values of
> lp->phy_type directly mapped to those of phy_interface_t.

Sadly, that's not the case. PHY_INTERFACE_MODE_* belong to a enum of twenty
different values, of which only _MII and _GMII overlap with XAW_PHY_*
values, but XAE_PHY_TYPE_RGMII_2_0 doesn't match
PHY_INTERFACE_MODE_RGMII_ID.

Regards
-- 
Alvaro G. M.


Re: [PATCH] [net-next] net/mlx5: include wq.o in non-ethernet build for FPGA

2017-07-02 Thread Saeed Mahameed
On Fri, Jun 30, 2017 at 10:25 PM, Arnd Bergmann  wrote:
> On Fri, Jun 30, 2017 at 8:58 PM, Ilan Tayari  wrote:
>
>>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
>>> b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
>>> index ca367445f864..50fe9e3c5dc2 100644
>>> --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
>>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
>>> @@ -9,7 +9,7 @@ mlx5_core-y :=main.o cmd.o debugfs.o fw.o eq.o uar.o
>>> pagealloc.o \
>>>  mlx5_core-$(CONFIG_MLX5_ACCEL) += accel/ipsec.o
>>>
>>>  mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o
>>> fpga/sdk.o \
>>> - fpga/ipsec.o
>>> + fpga/ipsec.o wq.o
>>
>> I believe we would prefer to move wq.o to mlx5_core-y.
>> Otherwise you might build it twice.
>
> That's not a problem, Kbuild is smart enough to drop duplicate object files
> that get built into the same module.
>
> If you think it's less confusing to readers of this file if it gets
> put into core,
> that's fine though, the only downside would be adding a little bit of
> code bloat for users that want neither the ethernet nor the fpga code
> (if that is a realistic use case).

Hi Arnd,

Thanks for the patch, your solution is good enough, but let's avoid
confusing developers with such duplications.
since the Makefile might get messy if we will keep using this method.

I suggest to move wq.o to core or make MLX5_FPGA depend on MLX5_CORE_EN.
I will discuss this with Ilan and we will provide the fix ASAP.

Thanks,
Saeed.


>
> Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 05/21] net-next: stmmac: Add dwmac-sun8i

2017-07-02 Thread Corentin Labbe
On Sat, Jul 01, 2017 at 02:42:14PM -0700, Florian Fainelli wrote:
> On 30/06/2017 23:53, Corentin Labbe wrote:
> > On Tue, Jun 27, 2017 at 10:37:34AM -0700, Florian Fainelli wrote:
> >> On 06/27/2017 10:29 AM, Maxime Ripard wrote:
> >>> On Tue, Jun 27, 2017 at 02:37:48PM +0200, Corentin Labbe wrote:
>  On Tue, Jun 27, 2017 at 11:33:56AM +0100, Andre Przywara wrote:
> > Hi,
> >
> > On 27/06/17 11:23, Icenowy Zheng wrote:
> >>
> >>
> >> 于 2017年6月27日 GMT+08:00 下午6:15:58, Andre Przywara 
> >>  写到:
> >>> Hi,
> >>>
> >>> On 27/06/17 10:41, Maxime Ripard wrote:
>  On Tue, Jun 27, 2017 at 10:02:45AM +0100, Andre Przywara wrote:
> > Hi,
> >
> > (CC:ing some people from that Rockchip dmwac series)
> >
> > On 27/06/17 09:21, Corentin Labbe wrote:
> >> On Tue, Jun 27, 2017 at 04:11:21PM +0800, Chen-Yu Tsai wrote:
> >>> On Tue, Jun 27, 2017 at 4:05 PM, Corentin Labbe
> >>>  wrote:
>  On Mon, Jun 26, 2017 at 01:18:23AM +0100, André Przywara wrote:
> > On 31/05/17 08:18, Corentin Labbe wrote:
> >> The dwmac-sun8i is a heavy hacked version of stmmac hardware by
> >> allwinner.
> >> In fact the only common part is the descriptor management and
> >>> the first
> >> register function.
> >
> > Hi,
> >
> > I know I am a bit late with this, but while adapting the U-Boot
> >>> driver
> > to the new binding I was wondering about the internal PHY
> >>> detection:
> >
> >
> > So here you seem to deduce the usage of the internal PHY by the
> >>> PHY
> > interface specified in the DT (MII = internal, RGMII =
> >>> external).
> > I think I raised this question before, but isn't it perfectly
> >>> legal for
> > a board to use MII with an external PHY even on those SoCs that
> >>> feature
> > an internal PHY?
> > On the first glance that does not make too much sense, but apart
> >>> from
> > not being the correct binding to describe all of the SoCs
> >>> features I see
> > two scenarios:
> > 1) A board vendor might choose to not use the internal PHY
> >>> because it
> > has bugs, lacks features (configurability) or has other issues.
> >>> For
> > instance I have heard reports that the internal PHY makes the
> >>> SoC go
> > rather hot, possibly limiting the CPU frequency. By using an
> >>> external
> > MII PHY (which are still cheaper than RGMII PHYs) this can be
> >>> avoided.
> > 2) A PHY does not necessarily need to be directly connected to
> > magnetics. Indeed quite some boards use (RG)MII to connect to a
> >>> switch
> > IC or some other network circuitry, for instance fibre
> >>> connectors.
> >
> > So I was wondering if we would need an explicit:
> >   allwinner,use-internal-phy;
> > boolean DT property to signal the usage of the internal PHY?
> > Alternatively we could go with the negative version:
> >   allwinner,disable-internal-phy;
> >
> > Or what about introducing a new "allwinner,internal-mii-phy"
> >>> compatible
> > string for the *PHY* node and use that?
> >
> > I just want to avoid that we introduce a binding that causes us
> > headaches later. I think we can still fix this with a followup
> >>> patch
> > before the driver and its binding hit a release kernel.
> >
> > Cheers,
> > Andre.
> >
> 
>  I just see some patch, where "phy-mode = internal" is valid.
>  I will try to find a way to use it
> >>>
> >>> Can you provide a link?
> >>
> >> https://lkml.org/lkml/2017/6/23/479
> >>
> >>>
> >>> I'm not a fan of using phy-mode for this. There's no guarantee
> >>> what
> >>> mode the internal PHY uses. That's what phy-mode is for.
> >
> > I can understand Chen-Yu's concerns, but ...
> >
> >> For each soc the internal PHY mode is know and setted in
> >>> emac_variant/internal_phy
> >> So its not a problem.
> >
> > that is true as well, at least for now.
> >
> > So while I agree that having a separate property to indicate
> > the usage of the internal PHY would be nice, I am bit tempted
> > to use this easier approach and piggy back on the existing
> > phy-mode property.
> 
>  We're trying to fix an issue that works for now 

Re: [PATCH][-next] net/mlx5: fix spelling mistake: "Allodating" -> "Allocating"

2017-07-02 Thread Saeed Mahameed
On Sun, Jul 2, 2017 at 12:40 AM, David Miller  wrote:
> From: Colin King 
> Date: Fri, 30 Jun 2017 11:59:22 +0100
>
>> From: Colin Ian King 
>>
>> Trivial fix to spelling mistake in mlx5_core_dbg debug message
>>
>> Signed-off-by: Colin Ian King 
>
> Applied, thanks Colin.
>
> Mellanox folks, I don't like how these lib/ objects are built.
>
> I absolutely depend upon being able to try and build individual
> object files, by name, in order to quickly smoke-test patches.
> Like this:
>
> [davem@kkuri net-next]$ make drivers/net/ethernet/mellanox/mlx5/core/lib/gid.o
>
> But I can't for these files:
>
> scripts/Makefile.build:44: 
> drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile: No such file or 
> directory
> make[1]: *** No rule to make target 
> 'drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile'.  Stop.
> Makefile:1663: recipe for target 
> 'drivers/net/ethernet/mellanox/mlx5/core/lib/gid.o' failed
>
> Please fix this so that I can build all object files by name in this driver
> again.

Hi Dave,
We are going to provide a fix ASAP.

>
> Thanks.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 12/12] qed: Add iWARP support for physical queue allocation

2017-07-02 Thread Michal Kalderon
iWARP has different physical queue requirements than RoCE

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 4060a6a..6c87bed 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -216,6 +216,10 @@ static u32 qed_get_pq_flags(struct qed_hwfn *p_hwfn)
case QED_PCI_ETH_ROCE:
flags |= PQ_FLAGS_MCOS | PQ_FLAGS_OFLD | PQ_FLAGS_LLT;
break;
+   case QED_PCI_ETH_IWARP:
+   flags |= PQ_FLAGS_MCOS | PQ_FLAGS_ACK | PQ_FLAGS_OOO |
+   PQ_FLAGS_OFLD;
+   break;
default:
DP_ERR(p_hwfn,
   "unknown personality %d\n", p_hwfn->hw_info.personality);
-- 
1.8.3.1



[PATCH net-next 11/12] qed: Add iWARP protocol support in context allocation

2017-07-02 Thread Michal Kalderon
When computing how much memory is required for the different hw clients
iWARP protocol should be taken into account

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_cxt.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c 
b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
index 38716f7..af106be 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
@@ -246,14 +246,16 @@ struct qed_cxt_mngr {
 static bool src_proto(enum protocol_type type)
 {
return type == PROTOCOLID_ISCSI ||
-  type == PROTOCOLID_FCOE;
+  type == PROTOCOLID_FCOE ||
+  type == PROTOCOLID_IWARP;
 }
 
 static bool tm_cid_proto(enum protocol_type type)
 {
return type == PROTOCOLID_ISCSI ||
   type == PROTOCOLID_FCOE ||
-  type == PROTOCOLID_ROCE;
+  type == PROTOCOLID_ROCE ||
+  type == PROTOCOLID_IWARP;
 }
 
 static bool tm_tid_proto(enum protocol_type type)
@@ -2068,6 +2070,11 @@ static void qed_rdma_set_pf_params(struct qed_hwfn 
*p_hwfn,
num_srqs = min_t(u32, 32 * 1024, p_params->num_srqs);
 
switch (p_hwfn->hw_info.personality) {
+   case QED_PCI_ETH_IWARP:
+   /* Each QP requires one connection */
+   num_cons = min_t(u32, IWARP_MAX_QPS, p_params->num_qps);
+   proto = PROTOCOLID_IWARP;
+   break;
case QED_PCI_ETH_ROCE:
num_qps = min_t(u32, ROCE_MAX_QPS, p_params->num_qps);
num_cons = num_qps * 2; /* each QP requires two connections */
@@ -2103,6 +2110,8 @@ int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 
rdma_tasks)
qed_cxt_set_proto_cid_count(p_hwfn, PROTOCOLID_CORE, core_cids, 0);
 
switch (p_hwfn->hw_info.personality) {
+   case QED_PCI_ETH_RDMA:
+   case QED_PCI_ETH_IWARP:
case QED_PCI_ETH_ROCE:
{
qed_rdma_set_pf_params(p_hwfn,
-- 
1.8.3.1



[PATCH net-next 10/12] qed: iWARP CM add error handling

2017-07-02 Thread Michal Kalderon
This patch introduces error handling for errors that occurred during
connection establishment.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 183 +++-
 include/linux/qed/qed_rdma_if.h |   9 ++
 2 files changed, 190 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index 84bcda3..5cd20da 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -1001,12 +1001,75 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, 
struct qed_rdma_qp *qp)
ep->state = QED_IWARP_EP_ESTABLISHED;
params.status = 0;
break;
+   case IWARP_CONN_ERROR_MPA_TIMEOUT:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA timeout\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -EBUSY;
+   break;
+   case IWARP_CONN_ERROR_MPA_ERROR_REJECT:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA Reject\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
+   case IWARP_CONN_ERROR_MPA_RST:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA reset(tcp cid: 0x%x)\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid,
+ ep->tcp_cid);
+   params.status = -ECONNRESET;
+   break;
+   case IWARP_CONN_ERROR_MPA_FIN:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA received FIN\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
+   case IWARP_CONN_ERROR_MPA_INSUF_IRD:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA insufficient ird\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
+   case IWARP_CONN_ERROR_MPA_RTR_MISMATCH:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA RTR MISMATCH\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
+   case IWARP_CONN_ERROR_MPA_INVALID_PACKET:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA Invalid Packet\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
+   case IWARP_CONN_ERROR_MPA_LOCAL_ERROR:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA Local Error\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
+   case IWARP_CONN_ERROR_MPA_TERMINATE:
+   DP_NOTICE(p_hwfn, "%s(0x%x) MPA TERMINATE\n",
+ QED_IWARP_CONNECT_MODE_STRING(ep), ep->cid);
+   params.status = -ECONNREFUSED;
+   break;
default:
params.status = -ECONNRESET;
break;
}
 
ep->event_cb(ep->cb_context, );
+
+   /* on passive side, if there is no associated QP (REJECT) we need to
+* return the ep to the pool, (in the regular case we add an element
+* in accept instead of this one.
+* In both cases we need to remove it from the ep_list.
+*/
+   if (fw_return_code != RDMA_RETURN_OK) {
+   ep->tcp_cid = QED_IWARP_INVALID_TCP_CID;
+   if ((ep->connect_mode == TCP_CONNECT_PASSIVE) &&
+   (!ep->qp)) {/* Rejected */
+   qed_iwarp_return_ep(p_hwfn, ep);
+   } else {
+   spin_lock_bh(_hwfn->p_rdma_info->iwarp.iw_lock);
+   list_del(>list_entry);
+   spin_unlock_bh(_hwfn->p_rdma_info->iwarp.iw_lock);
+   }
+   }
 }
 
 static void
@@ -2011,6 +2074,42 @@ void qed_iwarp_exception_received(struct qed_hwfn 
*p_hwfn,
params.event = QED_IWARP_EVENT_DISCONNECT;
event_cb = true;
break;
+   case IWARP_EXCEPTION_DETECTED_RQ_EMPTY:
+   params.event = QED_IWARP_EVENT_RQ_EMPTY;
+   event_cb = true;
+   break;
+   case IWARP_EXCEPTION_DETECTED_IRQ_FULL:
+   params.event = QED_IWARP_EVENT_IRQ_FULL;
+   event_cb = true;
+   break;
+   case IWARP_EXCEPTION_DETECTED_LLP_TIMEOUT:
+   params.event = QED_IWARP_EVENT_LLP_TIMEOUT;
+   event_cb = true;
+   break;
+   case IWARP_EXCEPTION_DETECTED_REMOTE_PROTECTION_ERROR:
+   params.event = QED_IWARP_EVENT_REMOTE_PROTECTION_ERROR;
+   event_cb = true;
+ 

[PATCH net-next 09/12] qed: iWARP implement disconnect flows

2017-07-02 Thread Michal Kalderon
This patch takes care of active/passive disconnect flows.
Disconnect flows can be initiated remotely, in which case a async event
will arrive from peer and indicated to qedr driver. These
are referred to as exceptions. When a QP is destroyed, it needs to check
that it's associated ep has been closed.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 90 -
 include/linux/qed/qed_rdma_if.h |  2 +
 2 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index a5da9fc..84bcda3 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -496,6 +496,8 @@ static void qed_iwarp_destroy_ep(struct qed_hwfn *p_hwfn,
 
 int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp)
 {
+   struct qed_iwarp_ep *ep = qp->ep;
+   int wait_count = 0;
int rc = 0;
 
if (qp->iwarp_state != QED_IWARP_QP_STATE_ERROR) {
@@ -505,6 +507,18 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct 
qed_rdma_qp *qp)
return rc;
}
 
+   /* Make sure ep is closed before returning and freeing memory. */
+   if (ep) {
+   while (ep->state != QED_IWARP_EP_CLOSED && wait_count++ < 200)
+   msleep(100);
+
+   if (ep->state != QED_IWARP_EP_CLOSED)
+   DP_NOTICE(p_hwfn, "ep state close timeout state=%x\n",
+ ep->state);
+
+   qed_iwarp_destroy_ep(p_hwfn, ep, false);
+   }
+
rc = qed_iwarp_fw_destroy(p_hwfn, qp);
 
if (qp->shared_queue)
@@ -1956,6 +1970,61 @@ int qed_iwarp_stop(struct qed_hwfn *p_hwfn, struct 
qed_ptt *p_ptt)
return qed_iwarp_ll2_stop(p_hwfn, p_ptt);
 }
 
+void qed_iwarp_qp_in_error(struct qed_hwfn *p_hwfn,
+  struct qed_iwarp_ep *ep, u8 fw_return_code)
+{
+   struct qed_iwarp_cm_event_params params;
+
+   qed_iwarp_modify_qp(p_hwfn, ep->qp, QED_IWARP_QP_STATE_ERROR, true);
+
+   params.event = QED_IWARP_EVENT_CLOSE;
+   params.ep_context = ep;
+   params.cm_info = >cm_info;
+   params.status = (fw_return_code == IWARP_QP_IN_ERROR_GOOD_CLOSE) ?
+0 : -ECONNRESET;
+
+   ep->state = QED_IWARP_EP_CLOSED;
+   spin_lock_bh(_hwfn->p_rdma_info->iwarp.iw_lock);
+   list_del(>list_entry);
+   spin_unlock_bh(_hwfn->p_rdma_info->iwarp.iw_lock);
+
+   ep->event_cb(ep->cb_context, );
+}
+
+void qed_iwarp_exception_received(struct qed_hwfn *p_hwfn,
+ struct qed_iwarp_ep *ep, int fw_ret_code)
+{
+   struct qed_iwarp_cm_event_params params;
+   bool event_cb = false;
+
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "EP(0x%x) fw_ret_code=%d\n",
+  ep->cid, fw_ret_code);
+
+   switch (fw_ret_code) {
+   case IWARP_EXCEPTION_DETECTED_LLP_CLOSED:
+   params.status = 0;
+   params.event = QED_IWARP_EVENT_DISCONNECT;
+   event_cb = true;
+   break;
+   case IWARP_EXCEPTION_DETECTED_LLP_RESET:
+   params.status = -ECONNRESET;
+   params.event = QED_IWARP_EVENT_DISCONNECT;
+   event_cb = true;
+   break;
+   default:
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA,
+  "Unhandled exception received...fw_ret_code=%d\n",
+  fw_ret_code);
+   break;
+   }
+
+   if (event_cb) {
+   params.ep_context = ep;
+   params.cm_info = >cm_info;
+   ep->event_cb(ep->cb_context, );
+   }
+}
+
 void
 qed_iwarp_connect_complete(struct qed_hwfn *p_hwfn,
   struct qed_iwarp_ep *ep, u8 fw_return_code)
@@ -2009,8 +2078,27 @@ static int qed_iwarp_async_event(struct qed_hwfn *p_hwfn,
   ep->tcp_cid, fw_return_code);
qed_iwarp_connect_complete(p_hwfn, ep, fw_return_code);
break;
-   /* Async event for active side only */
+   case IWARP_EVENT_TYPE_ASYNC_EXCEPTION_DETECTED:
+   if (!qed_iwarp_check_ep_ok(p_hwfn, ep))
+   return -EINVAL;
+   DP_VERBOSE(p_hwfn,
+  QED_MSG_RDMA,
+  "QP(0x%x) IWARP_EVENT_TYPE_ASYNC_EXCEPTION_DETECTED 
fw_ret_code=%d\n",
+  ep->cid, fw_return_code);
+   qed_iwarp_exception_received(p_hwfn, ep, fw_return_code);
+   break;
+   case IWARP_EVENT_TYPE_ASYNC_QP_IN_ERROR_STATE:
+   /* Async completion for Close Connection ramrod */
+   if (!qed_iwarp_check_ep_ok(p_hwfn, ep))
+   

[PATCH net-next 08/12] qed: iWARP CM add active side connect

2017-07-02 Thread Michal Kalderon
This patch implements the active side connect.
Offload a connection, process MPA reply and send RTR.
In some of the common passive/active functions, the active side
will work in blocking mode.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 240 ++--
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |   7 +
 drivers/net/ethernet/qlogic/qed/qed_rdma.c  |   4 +
 include/linux/qed/qed_rdma_if.h |  26 +++
 4 files changed, 265 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index a6dadae..a5da9fc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -611,7 +611,10 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct 
qed_rdma_qp *qp)
memset(_data, 0, sizeof(init_data));
init_data.cid = ep->tcp_cid;
init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
-   init_data.comp_mode = QED_SPQ_MODE_CB;
+   if (ep->connect_mode == TCP_CONNECT_PASSIVE)
+   init_data.comp_mode = QED_SPQ_MODE_CB;
+   else
+   init_data.comp_mode = QED_SPQ_MODE_EBLOCK;
 
rc = qed_sp_init_request(p_hwfn, _ent,
 IWARP_RAMROD_CMD_ID_TCP_OFFLOAD,
@@ -711,7 +714,7 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct 
qed_rdma_qp *qp)
DP_VERBOSE(p_hwfn, QED_MSG_RDMA,
   "private_data_len=%x handshake_mode=%x private_data=(%x)\n",
   async_data->mpa_request.ulp_data_len,
-  mpa_rev, *((u32 *)((u8 *)ep->ep_buffer_virt->in_pdata)));
+  mpa_rev, *((u32 *)(ep->ep_buffer_virt->in_pdata)));
 
if (mpa_rev == MPA_NEGOTIATION_TYPE_ENHANCED) {
/* Read ord/ird values from private data buffer */
@@ -801,7 +804,10 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct 
qed_rdma_qp *qp)
init_data.cid = reject ? ep->tcp_cid : qp->icid;
init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
 
-   init_data.comp_mode = QED_SPQ_MODE_EBLOCK;
+   if (ep->connect_mode == TCP_CONNECT_ACTIVE)
+   init_data.comp_mode = QED_SPQ_MODE_CB;
+   else
+   init_data.comp_mode = QED_SPQ_MODE_EBLOCK;
 
rc = qed_sp_init_request(p_hwfn, _ent,
 IWARP_RAMROD_CMD_ID_MPA_OFFLOAD,
@@ -890,6 +896,59 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct 
qed_rdma_qp *qp)
spin_unlock_bh(_hwfn->p_rdma_info->iwarp.iw_lock);
 }
 
+void
+qed_iwarp_parse_private_data(struct qed_hwfn *p_hwfn, struct qed_iwarp_ep *ep)
+{
+   struct mpa_v2_hdr *mpa_v2_params;
+   union async_output *async_data;
+   u16 mpa_ird, mpa_ord;
+   u8 mpa_data_size = 0;
+
+   if (MPA_REV2(p_hwfn->p_rdma_info->iwarp.mpa_rev)) {
+   mpa_v2_params =
+   (struct mpa_v2_hdr *)(ep->ep_buffer_virt->in_pdata);
+   mpa_data_size = sizeof(*mpa_v2_params);
+   mpa_ird = ntohs(mpa_v2_params->ird);
+   mpa_ord = ntohs(mpa_v2_params->ord);
+
+   ep->cm_info.ird = (u8)(mpa_ord & MPA_V2_IRD_ORD_MASK);
+   ep->cm_info.ord = (u8)(mpa_ird & MPA_V2_IRD_ORD_MASK);
+   }
+   async_data = >ep_buffer_virt->async_output;
+
+   ep->cm_info.private_data = ep->ep_buffer_virt->in_pdata + mpa_data_size;
+   ep->cm_info.private_data_len = async_data->mpa_response.ulp_data_len -
+  mpa_data_size;
+}
+
+void
+qed_iwarp_mpa_reply_arrived(struct qed_hwfn *p_hwfn, struct qed_iwarp_ep *ep)
+{
+   struct qed_iwarp_cm_event_params params;
+
+   if (ep->connect_mode == TCP_CONNECT_PASSIVE) {
+   DP_NOTICE(p_hwfn,
+ "MPA reply event not expected on passive side!\n");
+   return;
+   }
+
+   params.event = QED_IWARP_EVENT_ACTIVE_MPA_REPLY;
+
+   qed_iwarp_parse_private_data(p_hwfn, ep);
+
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA,
+  "MPA_NEGOTIATE (v%d): ORD: 0x%x IRD: 0x%x\n",
+  ep->mpa_rev, ep->cm_info.ord, ep->cm_info.ird);
+
+   params.cm_info = >cm_info;
+   params.ep_context = ep;
+   params.status = 0;
+
+   ep->mpa_reply_processed = true;
+
+   ep->event_cb(ep->cb_context, );
+}
+
 #define QED_IWARP_CONNECT_MODE_STRING(ep) \
((ep)->connect_mode == TCP_CONNECT_PASSIVE) ? "Passive" : "Active"
 
@@ -902,7 +961,13 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct 
qed_rdma_qp *qp)
 {
struct qed_iwarp_cm_event_params params;
 
-   params.event = QED_IWARP_EVENT_PASSIVE_COMPLETE;
+   if (ep->connect_mode == TCP_CONNECT_ACTIVE)
+   params.event = QED_IWARP_EVENT_ACTIVE_COMPLETE;
+   else
+   

[PATCH net-next 07/12] qed: iWARP CM add passive side connect

2017-07-02 Thread Michal Kalderon
This patch implements the passive side connect.
It addresses pre-allocating resources, creating a connection
element upon valid SYN packet received. Calling upper layer and
implementation of the accept/reject calls.

Error handling is not part of this patch.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h   |   2 +
 drivers/net/ethernet/qlogic/qed/qed_dev.c   |  11 +
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 939 +++-
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |  62 ++
 drivers/net/ethernet/qlogic/qed/qed_l2.c|  13 -
 drivers/net/ethernet/qlogic/qed/qed_rdma.h  |   2 +
 drivers/net/ethernet/qlogic/qed/qed_sp.h|   2 +
 include/linux/qed/common_hsi.h  |   2 +
 include/linux/qed/qed_rdma_if.h |  26 +-
 9 files changed, 1039 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index fd8cd5e..91003bc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -789,6 +789,8 @@ void qed_configure_vp_wfq_on_link_change(struct qed_dev 
*cdev,
 void qed_clean_wfq_db(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
 int qed_device_num_engines(struct qed_dev *cdev);
 int qed_device_get_port_id(struct qed_dev *cdev);
+void qed_set_fw_mac_addr(__le16 *fw_msb,
+__le16 *fw_mid, __le16 *fw_lsb, u8 *mac);
 
 #define QED_LEADING_HWFN(dev)   (>hwfns[0])
 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 6c8505d..4060a6a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -4127,3 +4127,14 @@ int qed_device_get_port_id(struct qed_dev *cdev)
 {
return (QED_LEADING_HWFN(cdev)->abs_pf_id) % qed_device_num_ports(cdev);
 }
+
+void qed_set_fw_mac_addr(__le16 *fw_msb,
+__le16 *fw_mid, __le16 *fw_lsb, u8 *mac)
+{
+   ((u8 *)fw_msb)[0] = mac[1];
+   ((u8 *)fw_msb)[1] = mac[0];
+   ((u8 *)fw_mid)[0] = mac[3];
+   ((u8 *)fw_mid)[1] = mac[2];
+   ((u8 *)fw_lsb)[0] = mac[5];
+   ((u8 *)fw_lsb)[1] = mac[4];
+}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index 2bab57c..a6dadae 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -44,9 +44,30 @@
 
 #define QED_IWARP_ORD_DEFAULT  32
 #define QED_IWARP_IRD_DEFAULT  32
+#define QED_IWARP_MAX_FW_MSS   4120
+
+#define QED_EP_SIG 0xecabcdef
+
+struct mpa_v2_hdr {
+   __be16 ird;
+   __be16 ord;
+};
+
+#define MPA_V2_PEER2PEER_MODEL  0x8000
+#define MPA_V2_SEND_RTR 0x4000 /* on ird */
+#define MPA_V2_READ_RTR 0x4000 /* on ord */
+#define MPA_V2_WRITE_RTR0x8000
+#define MPA_V2_IRD_ORD_MASK 0x3FFF
+
+#define MPA_REV2(_mpa_rev) ((_mpa_rev) == MPA_NEGOTIATION_TYPE_ENHANCED)
+
+#define QED_IWARP_INVALID_TCP_CID  0x
 #define QED_IWARP_RCV_WND_SIZE_DEF (256 * 1024)
 #define QED_IWARP_RCV_WND_SIZE_MIN (64 * 1024)
+#define TIMESTAMP_HEADER_SIZE  (12)
+
 #define QED_IWARP_TS_ENBIT(0)
+#define QED_IWARP_DA_ENBIT(1)
 #define QED_IWARP_PARAM_CRC_NEEDED (1)
 #define QED_IWARP_PARAM_P2P(1)
 
@@ -63,7 +84,8 @@ void qed_iwarp_init_devinfo(struct qed_hwfn *p_hwfn)
dev->max_inline = IWARP_REQ_MAX_INLINE_DATA_SIZE;
dev->max_qp = min_t(u32,
IWARP_MAX_QPS,
-   p_hwfn->p_rdma_info->num_qps);
+   p_hwfn->p_rdma_info->num_qps) -
+ QED_IWARP_PREALLOC_CNT;
 
dev->max_cq = dev->max_qp;
 
@@ -78,12 +100,22 @@ void qed_iwarp_init_hw(struct qed_hwfn *p_hwfn, struct 
qed_ptt *p_ptt)
p_hwfn->b_rdma_enabled_in_prs = true;
 }
 
+/* We have two cid maps, one for tcp which should be used only from passive
+ * syn processing and replacing a pre-allocated ep in the list. The second
+ * for active tcp and for QPs.
+ */
 static void qed_iwarp_cid_cleaned(struct qed_hwfn *p_hwfn, u32 cid)
 {
cid -= qed_cxt_get_proto_cid_start(p_hwfn, p_hwfn->p_rdma_info->proto);
 
spin_lock_bh(_hwfn->p_rdma_info->lock);
-   qed_bmap_release_id(p_hwfn, _hwfn->p_rdma_info->cid_map, cid);
+
+   if (cid < QED_IWARP_PREALLOC_CNT)
+   qed_bmap_release_id(p_hwfn, _hwfn->p_rdma_info->tcp_cid_map,
+   cid);
+   else
+   qed_bmap_release_id(p_hwfn, _hwfn->p_rdma_info->cid_map, cid);
+
spin_unlock_bh(_hwfn->p_rdma_info->lock);
 }
 
@@ -107,6 +139,45 @@ static int qed_iwarp_alloc_cid(struct qed_hwfn *p_hwfn, 
u32 *cid)
return rc;
 }
 
+static void 

[PATCH net-next 05/12] qed: iWARP CM - setup a ll2 connection for handling SYN packets

2017-07-02 Thread Michal Kalderon
iWARP handles incoming SYN packets using the ll2 interface. This patch
implements ll2 setup and teardown. Additional ll2 connections will
be used in the future which are not part of this patch series.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 211 +++-
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |  12 ++
 2 files changed, 220 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index a8bd5f8..f3b4b32 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -29,8 +29,11 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#include 
+#include 
 #include "qed_cxt.h"
 #include "qed_hw.h"
+#include "qed_ll2.h"
 #include "qed_rdma.h"
 #include "qed_reg_addr.h"
 #include "qed_sp.h"
@@ -474,12 +477,214 @@ void qed_iwarp_resc_free(struct qed_hwfn *p_hwfn)
 {
 }
 
+static int
+qed_iwarp_ll2_post_rx(struct qed_hwfn *p_hwfn,
+ struct qed_iwarp_ll2_buff *buf, u8 handle)
+{
+   int rc;
+
+   rc = qed_ll2_post_rx_buffer(p_hwfn, handle, buf->data_phys_addr,
+   (u16)buf->buff_size, buf, 1);
+   if (rc) {
+   DP_NOTICE(p_hwfn,
+ "Failed to repost rx buffer to ll2 rc = %d, 
handle=%d\n",
+ rc, handle);
+   dma_free_coherent(_hwfn->cdev->pdev->dev, buf->buff_size,
+ buf->data, buf->data_phys_addr);
+   kfree(buf);
+   }
+
+   return rc;
+}
+
+static void
+qed_iwarp_ll2_comp_syn_pkt(void *cxt, struct qed_ll2_comp_rx_data *data)
+{
+   struct qed_iwarp_ll2_buff *buf = data->cookie;
+   struct qed_hwfn *p_hwfn = cxt;
+
+   if (GET_FIELD(data->parse_flags,
+ PARSING_AND_ERR_FLAGS_L4CHKSMWASCALCULATED) &&
+   GET_FIELD(data->parse_flags, PARSING_AND_ERR_FLAGS_L4CHKSMERROR)) {
+   DP_NOTICE(p_hwfn, "Syn packet received with checksum error\n");
+   goto err;
+   }
+
+   /* Process SYN packet - added later on in series */
+
+err:
+   qed_iwarp_ll2_post_rx(p_hwfn, buf,
+ p_hwfn->p_rdma_info->iwarp.ll2_syn_handle);
+}
+
+static void qed_iwarp_ll2_rel_rx_pkt(void *cxt, u8 connection_handle,
+void *cookie, dma_addr_t rx_buf_addr,
+bool b_last_packet)
+{
+   struct qed_iwarp_ll2_buff *buffer = cookie;
+   struct qed_hwfn *p_hwfn = cxt;
+
+   dma_free_coherent(_hwfn->cdev->pdev->dev, buffer->buff_size,
+ buffer->data, buffer->data_phys_addr);
+   kfree(buffer);
+}
+
+static void qed_iwarp_ll2_comp_tx_pkt(void *cxt, u8 connection_handle,
+ void *cookie, dma_addr_t first_frag_addr,
+ bool b_last_fragment, bool b_last_packet)
+{
+   struct qed_iwarp_ll2_buff *buffer = cookie;
+   struct qed_hwfn *p_hwfn = cxt;
+
+   /* this was originally an rx packet, post it back */
+   qed_iwarp_ll2_post_rx(p_hwfn, buffer, connection_handle);
+}
+
+static void qed_iwarp_ll2_rel_tx_pkt(void *cxt, u8 connection_handle,
+void *cookie, dma_addr_t first_frag_addr,
+bool b_last_fragment, bool b_last_packet)
+{
+   struct qed_iwarp_ll2_buff *buffer = cookie;
+   struct qed_hwfn *p_hwfn = cxt;
+
+   if (!buffer)
+   return;
+
+   dma_free_coherent(_hwfn->cdev->pdev->dev, buffer->buff_size,
+ buffer->data, buffer->data_phys_addr);
+
+   kfree(buffer);
+}
+
+static int qed_iwarp_ll2_stop(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
+{
+   struct qed_iwarp_info *iwarp_info = _hwfn->p_rdma_info->iwarp;
+   int rc = 0;
+
+   if (iwarp_info->ll2_syn_handle != QED_IWARP_HANDLE_INVAL) {
+   rc = qed_ll2_terminate_connection(p_hwfn,
+ iwarp_info->ll2_syn_handle);
+   if (rc)
+   DP_INFO(p_hwfn, "Failed to terminate syn connection\n");
+
+   qed_ll2_release_connection(p_hwfn, iwarp_info->ll2_syn_handle);
+   iwarp_info->ll2_syn_handle = QED_IWARP_HANDLE_INVAL;
+   }
+
+   qed_llh_remove_mac_filter(p_hwfn,
+ p_ptt, p_hwfn->p_rdma_info->iwarp.mac_addr);
+   return rc;
+}
+
+static int
+qed_iwarp_ll2_alloc_buffers(struct qed_hwfn *p_hwfn,
+   int num_rx_bufs, int buff_size, u8 ll2_handle)
+{
+   struct qed_iwarp_ll2_buff *buffer;
+   int rc = 0;
+   int i;
+
+   for (i = 0; i < num_rx_bufs; 

[PATCH net-next 06/12] qed: iWARP CM add listener functions and initial SYN processing

2017-07-02 Thread Michal Kalderon
This patch adds the ability to add and remove listeners and identify
whether the SYN packet received is intended for iWARP or not. If
a listener is not found the SYN packet is posted back to the chip.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 269 +++-
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |  23 +++
 drivers/net/ethernet/qlogic/qed/qed_rdma.c  |   2 +
 include/linux/qed/qed_rdma_if.h |  52 ++
 4 files changed, 343 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index f3b4b32..2bab57c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -31,6 +31,10 @@
  */
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include "qed_cxt.h"
 #include "qed_hw.h"
 #include "qed_ll2.h"
@@ -477,6 +481,31 @@ void qed_iwarp_resc_free(struct qed_hwfn *p_hwfn)
 {
 }
 
+static void
+qed_iwarp_print_cm_info(struct qed_hwfn *p_hwfn,
+   struct qed_iwarp_cm_info *cm_info)
+{
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "ip_version = %d\n",
+  cm_info->ip_version);
+
+   if (cm_info->ip_version == QED_TCP_IPV4)
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA,
+  "remote_ip %pI4h:%x, local_ip %pI4h:%x vlan=%x\n",
+  cm_info->remote_ip, cm_info->remote_port,
+  cm_info->local_ip, cm_info->local_port,
+  cm_info->vlan);
+   else
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA,
+  "remote_ip %pI6h:%x, local_ip %pI6h:%x vlan=%x\n",
+  cm_info->remote_ip, cm_info->remote_port,
+  cm_info->local_ip, cm_info->local_port,
+  cm_info->vlan);
+
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA,
+  "private_data_len = %x ord = %d, ird = %d\n",
+  cm_info->private_data_len, cm_info->ord, cm_info->ird);
+}
+
 static int
 qed_iwarp_ll2_post_rx(struct qed_hwfn *p_hwfn,
  struct qed_iwarp_ll2_buff *buf, u8 handle)
@@ -497,11 +526,147 @@ void qed_iwarp_resc_free(struct qed_hwfn *p_hwfn)
return rc;
 }
 
+static struct qed_iwarp_listener *
+qed_iwarp_get_listener(struct qed_hwfn *p_hwfn,
+  struct qed_iwarp_cm_info *cm_info)
+{
+   struct qed_iwarp_listener *listener = NULL;
+   static const u32 ip_zero[4] = { 0, 0, 0, 0 };
+   bool found = false;
+
+   qed_iwarp_print_cm_info(p_hwfn, cm_info);
+
+   list_for_each_entry(listener,
+   _hwfn->p_rdma_info->iwarp.listen_list,
+   list_entry) {
+   if (listener->port == cm_info->local_port) {
+   if (!memcmp(listener->ip_addr,
+   ip_zero, sizeof(ip_zero))) {
+   found = true;
+   break;
+   }
+
+   if (!memcmp(listener->ip_addr,
+   cm_info->local_ip,
+   sizeof(cm_info->local_ip)) &&
+   (listener->vlan == cm_info->vlan)) {
+   found = true;
+   break;
+   }
+   }
+   }
+
+   if (found) {
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "listener found = %p\n",
+  listener);
+   return listener;
+   }
+
+   DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "listener not found\n");
+   return NULL;
+}
+
+static int
+qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn,
+  struct qed_iwarp_cm_info *cm_info,
+  void *buf,
+  u8 *remote_mac_addr,
+  u8 *local_mac_addr,
+  int *payload_len, int *tcp_start_offset)
+{
+   struct vlan_ethhdr *vethh;
+   bool vlan_valid = false;
+   struct ipv6hdr *ip6h;
+   struct ethhdr *ethh;
+   struct tcphdr *tcph;
+   struct iphdr *iph;
+   int eth_hlen;
+   int ip_hlen;
+   int eth_type;
+   int i;
+
+   ethh = buf;
+   eth_type = ntohs(ethh->h_proto);
+   if (eth_type == ETH_P_8021Q) {
+   vlan_valid = true;
+   vethh = (struct vlan_ethhdr *)ethh;
+   cm_info->vlan = ntohs(vethh->h_vlan_TCI) & VLAN_VID_MASK;
+   eth_type = ntohs(vethh->h_vlan_encapsulated_proto);
+   }
+
+   eth_hlen = ETH_HLEN + (vlan_valid ? sizeof(u32) : 0);
+
+   memcpy(remote_mac_addr, ethh->h_source, ETH_ALEN);
+
+   memcpy(local_mac_addr, ethh->h_dest, ETH_ALEN);
+
+   

[PATCH net-next 04/12] qed: Add iWARP support in ll2 connections

2017-07-02 Thread Michal Kalderon
Add a new connection type for iWARP ll2 connections for setting
correct ll2 filters and connection type to FW.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 13 +++--
 include/linux/qed/qed_ll2_if.h|  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c 
b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index e235fb2..c06ad4f 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -896,7 +896,8 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn 
*p_hwfn,
p_ramrod->main_func_queue = (conn_type == QED_LL2_TYPE_OOO) ? 0 : 1;
 
if ((IS_MF_DEFAULT(p_hwfn) || IS_MF_SI(p_hwfn)) &&
-   p_ramrod->main_func_queue && (conn_type != QED_LL2_TYPE_ROCE)) {
+   p_ramrod->main_func_queue && (conn_type != QED_LL2_TYPE_ROCE) &&
+   (conn_type != QED_LL2_TYPE_IWARP)) {
p_ramrod->mf_si_bcast_accept_all = 1;
p_ramrod->mf_si_mcast_accept_all = 1;
} else {
@@ -972,12 +973,20 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn 
*p_hwfn,
p_ramrod->conn_type = PROTOCOLID_FCOE;
break;
case QED_LL2_TYPE_ISCSI:
-   case QED_LL2_TYPE_OOO:
p_ramrod->conn_type = PROTOCOLID_ISCSI;
break;
case QED_LL2_TYPE_ROCE:
p_ramrod->conn_type = PROTOCOLID_ROCE;
break;
+   case QED_LL2_TYPE_IWARP:
+   p_ramrod->conn_type = PROTOCOLID_IWARP;
+   break;
+   case QED_LL2_TYPE_OOO:
+   if (p_hwfn->hw_info.personality == QED_PCI_ISCSI)
+   p_ramrod->conn_type = PROTOCOLID_ISCSI;
+   else
+   p_ramrod->conn_type = PROTOCOLID_IWARP;
+   break;
default:
p_ramrod->conn_type = PROTOCOLID_ETH;
DP_NOTICE(p_hwfn, "Unknown connection type: %d\n", conn_type);
diff --git a/include/linux/qed/qed_ll2_if.h b/include/linux/qed/qed_ll2_if.h
index c9c56bc..dd7a3b8 100644
--- a/include/linux/qed/qed_ll2_if.h
+++ b/include/linux/qed/qed_ll2_if.h
@@ -50,6 +50,7 @@ enum qed_ll2_conn_type {
QED_LL2_TYPE_OOO,
QED_LL2_TYPE_RESERVED2,
QED_LL2_TYPE_ROCE,
+   QED_LL2_TYPE_IWARP,
QED_LL2_TYPE_RESERVED3,
MAX_QED_LL2_RX_CONN_TYPE
 };
-- 
1.8.3.1



[PATCH net-next 03/12] qed: Rename some ll2 related defines

2017-07-02 Thread Michal Kalderon
Make some names more generic as they will be used by iWARP too.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h |  2 +-
 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 29 ++---
 include/linux/qed/qed_ll2_if.h|  2 +-
 3 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 22e1171..fd8cd5e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -779,7 +779,7 @@ static inline u8 qed_concrete_to_sw_fid(struct qed_dev 
*cdev,
 }
 
 #define PURE_LB_TC 8
-#define OOO_LB_TC 9
+#define PKT_LB_TC 9
 
 int qed_configure_vport_wfq(struct qed_dev *cdev, u16 vp_id, u32 rate);
 void qed_configure_vp_wfq_on_link_change(struct qed_dev *cdev,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c 
b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index be66f19..e235fb2 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -309,7 +309,7 @@ static void qed_ll2_txq_flush(struct qed_hwfn *p_hwfn, u8 
connection_handle)
list_del(_pkt->list_entry);
b_last_packet = list_empty(_tx->active_descq);
list_add_tail(_pkt->list_entry, _tx->free_descq);
-   if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_ISCSI_OOO) {
+   if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) {
struct qed_ooo_buffer *p_buffer;
 
p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie;
@@ -532,7 +532,7 @@ static void qed_ll2_rxq_flush(struct qed_hwfn *p_hwfn, u8 
connection_handle)
 
list_move_tail(_pkt->list_entry, _rx->free_descq);
 
-   if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_ISCSI_OOO) {
+   if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) {
struct qed_ooo_buffer *p_buffer;
 
p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie;
@@ -893,8 +893,7 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn 
*p_hwfn,
p_ramrod->drop_ttl0_flg = p_ll2_conn->input.rx_drop_ttl0_flg;
p_ramrod->inner_vlan_removal_en = p_ll2_conn->input.rx_vlan_removal_en;
p_ramrod->queue_id = p_ll2_conn->queue_id;
-   p_ramrod->main_func_queue = (conn_type == QED_LL2_TYPE_ISCSI_OOO) ? 0
- : 1;
+   p_ramrod->main_func_queue = (conn_type == QED_LL2_TYPE_OOO) ? 0 : 1;
 
if ((IS_MF_DEFAULT(p_hwfn) || IS_MF_SI(p_hwfn)) &&
p_ramrod->main_func_queue && (conn_type != QED_LL2_TYPE_ROCE)) {
@@ -924,7 +923,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn 
*p_hwfn,
if (!QED_LL2_TX_REGISTERED(p_ll2_conn))
return 0;
 
-   if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_ISCSI_OOO)
+   if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO)
p_ll2_conn->tx_stats_en = 0;
else
p_ll2_conn->tx_stats_en = 1;
@@ -955,10 +954,10 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn 
*p_hwfn,
p_ramrod->pbl_size = cpu_to_le16(pbl_size);
 
switch (p_ll2_conn->input.tx_tc) {
-   case LB_TC:
+   case PURE_LB_TC:
pq_id = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_LB);
break;
-   case OOO_LB_TC:
+   case PKT_LB_TC:
pq_id = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_OOO);
break;
default:
@@ -973,7 +972,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn 
*p_hwfn,
p_ramrod->conn_type = PROTOCOLID_FCOE;
break;
case QED_LL2_TYPE_ISCSI:
-   case QED_LL2_TYPE_ISCSI_OOO:
+   case QED_LL2_TYPE_OOO:
p_ramrod->conn_type = PROTOCOLID_ISCSI;
break;
case QED_LL2_TYPE_ROCE:
@@ -1142,7 +1141,7 @@ static int qed_ll2_acquire_connection_tx(struct qed_hwfn 
*p_hwfn,
u16 buf_idx;
int rc = 0;
 
-   if (p_ll2_info->input.conn_type != QED_LL2_TYPE_ISCSI_OOO)
+   if (p_ll2_info->input.conn_type != QED_LL2_TYPE_OOO)
return rc;
 
/* Correct number of requested OOO buffers if needed */
@@ -1280,7 +1279,7 @@ int qed_ll2_acquire_connection(void *cxt, struct 
qed_ll2_acquire_data *data)
goto q_allocate_fail;
 
/* Register callbacks for the Rx/Tx queues */
-   if (data->input.conn_type == QED_LL2_TYPE_ISCSI_OOO) {
+   if (data->input.conn_type == QED_LL2_TYPE_OOO) {
comp_rx_cb = qed_ll2_lb_rxq_completion;
comp_tx_cb = qed_ll2_lb_txq_completion;
} else {
@@ -1339,7 +1338,7 @@ static int qed_ll2_establish_connection_rx(struct 
qed_hwfn *p_hwfn,
 

[PATCH net-next 02/12] qed: Implement iWARP initialization, teardown and qp operations

2017-07-02 Thread Michal Kalderon
This patch adds iWARP support for flows that have common code
between RoCE and iWARP, such as initialization, teardown and
qp setup verbs: create, destroy, modify, query.
It introduces the iWARP specific files qed_iwarp.[ch] and
iwarp_common.h

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/Makefile|   2 +-
 drivers/net/ethernet/qlogic/qed/qed_dev.c   |   9 +-
 drivers/net/ethernet/qlogic/qed/qed_hsi.h   |   1 +
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 531 
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |  85 +
 drivers/net/ethernet/qlogic/qed/qed_rdma.c  | 133 +--
 drivers/net/ethernet/qlogic/qed/qed_rdma.h  |   3 +
 drivers/net/ethernet/qlogic/qed/qed_roce.c  |  20 ++
 drivers/net/ethernet/qlogic/qed/qed_sp.h|   5 +-
 include/linux/qed/iwarp_common.h|  53 +++
 include/linux/qed/qed_rdma_if.h |   1 +
 11 files changed, 803 insertions(+), 40 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_iwarp.c
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_iwarp.h
 create mode 100644 include/linux/qed/iwarp_common.h

diff --git a/drivers/net/ethernet/qlogic/qed/Makefile 
b/drivers/net/ethernet/qlogic/qed/Makefile
index 6745238..82dd470 100644
--- a/drivers/net/ethernet/qlogic/qed/Makefile
+++ b/drivers/net/ethernet/qlogic/qed/Makefile
@@ -5,6 +5,6 @@ qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o 
qed_init_ops.o \
 qed_selftest.o qed_dcbx.o qed_debug.o qed_ptp.o
 qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o
 qed-$(CONFIG_QED_LL2) += qed_ll2.o
-qed-$(CONFIG_QED_RDMA) += qed_roce.o qed_rdma.o
+qed-$(CONFIG_QED_RDMA) += qed_roce.o qed_rdma.o qed_iwarp.o
 qed-$(CONFIG_QED_ISCSI) += qed_iscsi.o qed_ooo.o
 qed-$(CONFIG_QED_FCOE) += qed_fcoe.o
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 68e6182..6c8505d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -937,8 +937,15 @@ int qed_resc_alloc(struct qed_dev *cdev)
/* EQ */
n_eqes = qed_chain_get_capacity(_hwfn->p_spq->chain);
if (QED_IS_RDMA_PERSONALITY(p_hwfn)) {
+   enum protocol_type rdma_proto;
+
+   if (QED_IS_ROCE_PERSONALITY(p_hwfn))
+   rdma_proto = PROTOCOLID_ROCE;
+   else
+   rdma_proto = PROTOCOLID_IWARP;
+
num_cons = qed_cxt_get_proto_cid_count(p_hwfn,
-  PROTOCOLID_ROCE,
+  rdma_proto,
   NULL) * 2;
n_eqes += num_cons + 2 * MAX_NUM_VFS_BB;
} else if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index 3bf3614..31fb0bf 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
new file mode 100644
index 000..a8bd5f8
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -0,0 +1,531 @@
+/* QLogic qed NIC Driver
+ * Copyright (c) 2015-2017  QLogic Corporation
+ *
+ * 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, 

[PATCH net-next 01/12] qed: Introduce iWARP personality

2017-07-02 Thread Michal Kalderon
iWARP personality introduced the need for differentiating in several
places in the code whether we are RoCE, iWARP or either. This
leads to introducing new macros for querying the personality.

Signed-off-by: Michal Kalderon 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h  | 26 +++---
 drivers/net/ethernet/qlogic/qed/qed_cxt.c  |  8 
 drivers/net/ethernet/qlogic/qed/qed_dev.c  | 12 +---
 drivers/net/ethernet/qlogic/qed/qed_l2.c   |  3 +--
 drivers/net/ethernet/qlogic/qed/qed_ll2.c  |  2 +-
 drivers/net/ethernet/qlogic/qed/qed_main.c | 17 -
 include/linux/qed/common_hsi.h |  2 +-
 7 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 14b08ee..22e1171 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -210,14 +210,16 @@ struct qed_tunn_update_params {
 
 /* The PCI personality is not quite synonymous to protocol ID:
  * 1. All personalities need CORE connections
- * 2. The Ethernet personality may support also the RoCE protocol
+ * 2. The Ethernet personality may support also the RoCE/iWARP protocol
  */
 enum qed_pci_personality {
QED_PCI_ETH,
QED_PCI_FCOE,
QED_PCI_ISCSI,
QED_PCI_ETH_ROCE,
-   QED_PCI_DEFAULT /* default in shmem */
+   QED_PCI_ETH_IWARP,
+   QED_PCI_ETH_RDMA,
+   QED_PCI_DEFAULT, /* default in shmem */
 };
 
 /* All VFs are symmetric, all counters are PF + all VFs */
@@ -277,6 +279,7 @@ enum qed_dev_cap {
QED_DEV_CAP_FCOE,
QED_DEV_CAP_ISCSI,
QED_DEV_CAP_ROCE,
+   QED_DEV_CAP_IWARP,
 };
 
 enum qed_wol_support {
@@ -286,7 +289,24 @@ enum qed_wol_support {
 
 struct qed_hw_info {
/* PCI personality */
-   enum qed_pci_personalitypersonality;
+   enum qed_pci_personality personality;
+#define QED_IS_RDMA_PERSONALITY(dev)   \
+   ((dev)->hw_info.personality == QED_PCI_ETH_ROCE ||  \
+(dev)->hw_info.personality == QED_PCI_ETH_IWARP || \
+(dev)->hw_info.personality == QED_PCI_ETH_RDMA)
+#define QED_IS_ROCE_PERSONALITY(dev)  \
+   ((dev)->hw_info.personality == QED_PCI_ETH_ROCE || \
+(dev)->hw_info.personality == QED_PCI_ETH_RDMA)
+#define QED_IS_IWARP_PERSONALITY(dev)  \
+   ((dev)->hw_info.personality == QED_PCI_ETH_IWARP || \
+(dev)->hw_info.personality == QED_PCI_ETH_RDMA)
+#define QED_IS_L2_PERSONALITY(dev)   \
+   ((dev)->hw_info.personality == QED_PCI_ETH || \
+QED_IS_RDMA_PERSONALITY(dev))
+#define QED_IS_FCOE_PERSONALITY(dev) \
+   ((dev)->hw_info.personality == QED_PCI_FCOE)
+#define QED_IS_ISCSI_PERSONALITY(dev) \
+   ((dev)->hw_info.personality == QED_PCI_ISCSI)
 
/* Resource Allocation scheme results */
u32 resc_start[QED_MAX_RESC];
diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c 
b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
index e201214..38716f7 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
@@ -853,7 +853,7 @@ u32 qed_cxt_cfg_ilt_compute_excess(struct qed_hwfn *p_hwfn, 
u32 used_lines)
if (!excess_lines)
return 0;
 
-   if (p_hwfn->hw_info.personality != QED_PCI_ETH_ROCE)
+   if (!QED_IS_RDMA_PERSONALITY(p_hwfn))
return 0;
 
p_mngr = p_hwfn->p_cxt_mngr;
@@ -1033,7 +1033,7 @@ static int qed_ilt_blk_alloc(struct qed_hwfn *p_hwfn,
u32 lines, line, sz_left, lines_to_skip = 0;
 
/* Special handling for RoCE that supports dynamic allocation */
-   if ((p_hwfn->hw_info.personality == QED_PCI_ETH_ROCE) &&
+   if (QED_IS_RDMA_PERSONALITY(p_hwfn) &&
((ilt_client == ILT_CLI_CDUT) || ilt_client == ILT_CLI_TSDM))
return 0;
 
@@ -1833,7 +1833,7 @@ static void qed_tm_init_pf(struct qed_hwfn *p_hwfn)
tm_offset += tm_iids.pf_tids[i];
}
 
-   if (p_hwfn->hw_info.personality == QED_PCI_ETH_ROCE)
+   if (QED_IS_RDMA_PERSONALITY(p_hwfn))
active_seg_mask = 0;
 
STORE_RT_REG(p_hwfn, TM_REG_PF_ENABLE_TASK_RT_OFFSET, active_seg_mask);
@@ -2344,7 +2344,7 @@ int qed_cxt_get_tid_mem_info(struct qed_hwfn *p_hwfn,
   last_cid_allocated - 1);
 
if (!p_hwfn->b_rdma_enabled_in_prs) {
-   /* Enable RoCE search */
+   /* Enable RDMA search */
qed_wr(p_hwfn, p_ptt, p_hwfn->rdma_prs_search_reg, 1);
p_hwfn->b_rdma_enabled_in_prs = true;
}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 

[PATCH net-next 00/12] qed: Add iWARP support for QL4xxxx

2017-07-02 Thread Michal Kalderon
This patch series adds iWARP support to our QL4 networking adapters.
The code changes span across qed and qedr drivers, but this series contains
changes to qed only. Once the series is accepted, the qedr series will
be submitted to the rdma tree.
There is one additional qed patch which enables the iWARP, this patch is
delayed until the qedr series will be accepted. 

The patches were previously sent as an RFC, and these are the first 12
patches in the RFC series:
https://www.spinics.net/lists/linux-rdma/msg51416.html

This series was tested and built against net-next.

MAINTAINERS file is not updated in this PATCH as there is a pending patch
for qedr driver update https://patchwork.kernel.org/patch/9752761.

Michal Kalderon (12):
  qed: Introduce iWARP personality
  qed: Implement iWARP initialization, teardown and qp operations
  qed: Rename some ll2 related defines
  qed: Add iWARP support in ll2 connections
  qed: iWARP CM - setup a ll2 connection for handling SYN packets
  qed: iWARP CM add listener functions and initial SYN processing
  qed: iWARP CM add passive side connect
  qed: iWARP CM add active side connect
  qed: iWARP implement disconnect flows
  qed: iWARP CM add error handling
  qed: Add iWARP protocol support in context allocation
  qed: Add iWARP support for physical queue allocation

 drivers/net/ethernet/qlogic/qed/Makefile|2 +-
 drivers/net/ethernet/qlogic/qed/qed.h   |   30 +-
 drivers/net/ethernet/qlogic/qed/qed_cxt.c   |   21 +-
 drivers/net/ethernet/qlogic/qed/qed_dev.c   |   36 +-
 drivers/net/ethernet/qlogic/qed/qed_hsi.h   |1 +
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 2409 +++
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |  189 +++
 drivers/net/ethernet/qlogic/qed/qed_l2.c|   16 +-
 drivers/net/ethernet/qlogic/qed/qed_ll2.c   |   42 +-
 drivers/net/ethernet/qlogic/qed/qed_main.c  |   17 +-
 drivers/net/ethernet/qlogic/qed/qed_rdma.c  |  139 +-
 drivers/net/ethernet/qlogic/qed/qed_rdma.h  |5 +
 drivers/net/ethernet/qlogic/qed/qed_roce.c  |   20 +
 drivers/net/ethernet/qlogic/qed/qed_sp.h|7 +-
 include/linux/qed/common_hsi.h  |4 +-
 include/linux/qed/iwarp_common.h|   53 +
 include/linux/qed/qed_ll2_if.h  |3 +-
 include/linux/qed/qed_rdma_if.h |  114 ++
 18 files changed, 3008 insertions(+), 100 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_iwarp.c
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_iwarp.h
 create mode 100644 include/linux/qed/iwarp_common.h

-- 
1.8.3.1



Re: [PATCH net-next v5 07/16] bpf: Add setsockopt helper function to bpf

2017-07-02 Thread kbuild test robot
Hi Lawrence,

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Lawrence-Brakmo/bpf-Adding-support-for-sock_ops/20170701-203039
config: x86_64-randconfig-i0-07010430 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `bpf_setsockopt':
>> (.text+0x5bb69): undefined reference to `tcp_setsockopt'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip