net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)
Dexuan Cui
maintainerPATCH v6 1/1 net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)
Add a VF driver for Microsoft Azure Network Adapter (MANA) that will be available in the future.
--- MAINTAINERS | 4 +- drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/microsoft/Kconfig | 29 + drivers/net/ethernet/microsoft/Makefile | 5 + drivers/net/ethernet/microsoft/mana/Makefile | 6 + drivers/net/ethernet/microsoft/mana/gdma.h | 702 ++++++ .../net/ethernet/microsoft/mana/gdma_main.c | 1423 ++++++++++++ .../net/ethernet/microsoft/mana/hw_channel.c | 849 ++++++++ .../net/ethernet/microsoft/mana/hw_channel.h | 190 ++ drivers/net/ethernet/microsoft/mana/mana.h | 551 +++++ drivers/net/ethernet/microsoft/mana/mana_en.c | 1916 +++++++++++++++++ .../ethernet/microsoft/mana/mana_ethtool.c | 250 +++ .../net/ethernet/microsoft/mana/shm_channel.c | 291 +++ .../net/ethernet/microsoft/mana/shm_channel.h | 21 + drivers/net/hyperv/netvsc_drv.c | 14 +- 16 files changed, 6250 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/microsoft/Kconfig create mode 100644 drivers/net/ethernet/microsoft/Makefile create mode 100644 drivers/net/ethernet/microsoft/mana/Makefile create mode 100644 drivers/net/ethernet/microsoft/mana/gdma.h create mode 100644 drivers/net/ethernet/microsoft/mana/gdma_main.c create mode 100644 drivers/net/ethernet/microsoft/mana/hw_channel.c create mode 100644 drivers/net/ethernet/microsoft/mana/hw_channel.h create mode 100644 drivers/net/ethernet/microsoft/mana/mana.h create mode 100644 drivers/net/ethernet/microsoft/mana/mana_en.c create mode 100644 drivers/net/ethernet/microsoft/mana/mana_ethtool.c create mode 100644 drivers/net/ethernet/microsoft/mana/shm_channel.c create mode 100644 drivers/net/ethernet/microsoft/mana/shm_channel.h
Changes in v2:
Removed the module_param(num_queues,...). [Andrew Lunn]
Changed pr_err() to netdev_err() and dev_err(). [Andrew Lunn]
Used reverse X-mas tree style in all the functions. [Andrew Lunn]
Changed "= { 0 };" to "= {};" for struct variables. [Leon Romanovsky]
Addressed 3 build failures on i386, arc and powerpc by making the the driver dependent on X86_64 in Kconfig: so far, the driver is only validated on X86_64 (in the future, we may enable the driver for ARM64).
Also made some cosmetic changes.
Rebased the patch to the latest net-next.
BTW, the support of XDP and BQL haven't been implemented. They are on our TO-DO list.
Changes in v3:
Changed the Kconfig file:
Microsoft Azure Network Device ==> Microsoft Network Devices Drop the default m
validated ==> supported
Fixed some warnings reported by "kernel test robot" (there are
still some warnings against another driver pci-hyperv.c, which I'll fix in a separate patch for the PCI tree).
Changes in v4:
Removed all the "__packed" usages since all the structs are actually naturally aligned. We verified there is no hole n the middle of the structs or at the end of the structs.
Prefixed all the functions with "mana_".
Integrated Shachar Raindel's multi-vPort patches (i.e. create multiple net devices on the single VF PCIe device, if the PF driver reports the support). Added Shachar's Co-developed-by and Signed-off-by.
Also made some cosmetic changes.
Rebased the patch to the latest net-next.
Changes in v5:
Made a small change to drivers/net/hyperv/netvsc_drv.c's get_netvsc_byslot(): now with the multi-vPorts-per-PCI-dev, the netvsc driver needs to check both the serial number and the MAC address to find the matching vPort net device. Note: this change doesn't break any existing VF drivers.
Prefixed all the functions with "mana_". (Previously some were missed). Now there is no "ana" or "ANA" in the code.
Changed the "drv version" to "proto version". We don't have driver version. The correct name in mana_query_device_cfg() should be "proto version".
Fixed the defines and the struct field names accordingly.
Used ethtool_rxfh_indir_default() rather than direct "i % apc->num_queues;"
Handled the error in case netif_set_real_num_tx_queues() fails.
Used register_netdev() since we don't really need to explicitly get and release the RTNL lock.
Changed some WARN_ON()'s to WARN_ON_ONCE()'s. Removed a few unnecessary WARN_ON()'s.
Used "WARN_ON(xxx);" rather than "if (xxx) WARN_ON(1);"
Used "return foo();" rather than "err = foo(); return err;" in several places.
Removed unnecessary checking in mana_set_channels().
Also made some small cosmetic changes.
Rebased the patch to the latest net-next.
Changes in v6:
Used mana_do_attach()/mana_detach() in mana_open()/mana_close(). This way the related resources (e.g. SQ, RQ, etc.) are not allocated until the net interface goes UP.
Fixed IRQ allocation for the multi-vPorts case. Currently each vPort has its own event queues (EQs), and in future we'll share EQs among all the vPorts (a vPort means a net_device).
Added smp_rmb() in mana_poll_tx_cq(): ensure checking txq_stopped before checking apc->port_is_up.
Used PAGE_ALIGNED(), PAGE_ALIGN(), PHYS_PFN() where appropriate.
Removed some code that isn't really used at present, e.g. the below flags are not really used at present:
GDMA_WR_SGL_DIRECT
GDMA_WR_CONSUME_CREDIT
GDMA_WR_FENCE
GDMA_WR_CHECK_SN
so removed the code using the flags, mainly in mana_gd_write_sgl() and mana_gd_write_client_oob().
Removed unused event types in mana_gd_process_eqe(), and also simplified the function a little bit.
Rebased the patch to the latest net-next.
MAINTAINERS +3 -1
@@ -8260,11 +8260,12 @@ S: Maintained T: git git://linuxtv.org/media_tree.git F: drivers/media/i2c/hi556.c -Hyper-V CORE AND DRIVERS +Hyper-V/Azure CORE AND DRIVERS M: "K. Y. Srinivasan" <[email protected]> M: Haiyang Zhang <[email protected]> M: Stephen Hemminger <[email protected]> M: Wei Liu <[email protected]> +M: Dexuan Cui <[email protected]> L: [email protected] S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
@@ -8281,6 +8282,7 @@ F: drivers/hid/hid-hyperv.c F: drivers/hv/ F: drivers/input/serio/hyperv-keyboard.c F: drivers/iommu/hyperv-iommu.c +F: drivers/net/ethernet/microsoft/ F: drivers/net/hyperv/ F: drivers/pci/controller/pci-hyperv-intf.c F: drivers/pci/controller/pci-hyperv.c
drivers/net/ethernet/Kconfig +1 -0
@@ -82,6 +82,7 @@ source "drivers/net/ethernet/huawei/Kconfig" source "drivers/net/ethernet/i825xx/Kconfig" source "drivers/net/ethernet/ibm/Kconfig" source "drivers/net/ethernet/intel/Kconfig" +source "drivers/net/ethernet/microsoft/Kconfig" source "drivers/net/ethernet/xscale/Kconfig" config JME
drivers/net/ethernet/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_NET_VENDOR_HUAWEI) += huawei/ obj-$(CONFIG_NET_VENDOR_IBM) += ibm/ obj-$(CONFIG_NET_VENDOR_INTEL) += intel/ obj-$(CONFIG_NET_VENDOR_I825XX) += i825xx/ +obj-$(CONFIG_NET_VENDOR_MICROSOFT) += microsoft/ obj-$(CONFIG_NET_VENDOR_XSCALE) += xscale/ obj-$(CONFIG_JME) += jme.o obj-$(CONFIG_KORINA) += korina.o
drivers/net/ethernet/microsoft/Kconfig new file +29 -0
@@ -0,0 +1,29 @@ +# +# Microsoft Azure network device configuration +# + +config NET_VENDOR_MICROSOFT + bool "Microsoft Network Devices" + default y + help + If you have a network (Ethernet) device belonging to this class, say Y. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip the + question about Microsoft network devices. If you say Y, you will be + asked for your specific device in the following question. + +if NET_VENDOR_MICROSOFT + +config MICROSOFT_MANA + tristate "Microsoft Azure Network Adapter (MANA) support" + depends on PCI_MSI && X86_64 + select PCI_HYPERV + help + This driver supports Microsoft Azure Network Adapter (MANA). + So far, the driver is only supported on X86_64. + + To compile this driver as a module, choose M here. + The module will be called mana. + +endif #NET_VENDOR_MICROSOFT
drivers/net/ethernet/microsoft/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the Microsoft Azure network device driver. +# + +obj-$(CONFIG_MICROSOFT_MANA) += mana/
drivers/net/ethernet/microsoft/mana/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +# +# Makefile for the Microsoft Azure Network Adapter driver + +obj-$(CONFIG_MICROSOFT_MANA) += mana.o +mana-objs := gdma_main.o shm_channel.o hw_channel.o mana_en.o mana_ethtool.o
drivers/net/ethernet/microsoft/mana/gdma.h new file +702 -0
702 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +1423 -0
1,423 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/hw_channel.c new file +849 -0
801 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/hw_channel.h new file +190 -0
190 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/mana.h new file +551 -0
551 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/mana_en.c new file +1916 -0
1,916 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/mana_ethtool.c new file +250 -0
250 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/shm_channel.c new file +291 -0
291 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/shm_channel.h new file +21 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.20.1
Part of the diff is not shown here. View the raw message.
Jakub Kicinski
maintainerdrivers/net/ethernet/microsoft/mana/gdma_main.c line 131
Quoted 2 lines · On Wed, 14 Apr 2021 22:45:19 -0700 Dexuan Cui wrote:
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +2
-0+ buf =dma_alloc_coherent (gmi->dev, length, &dma_handle, +GFP_KERNEL | __GFP_ZERO);
No need for GFP_ZERO, dma_alloc_coherent() zeroes the memory these days.
drivers/net/ethernet/microsoft/mana/gdma_main.c line 418
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +5
-0+static int mana_gd_register_irq(struct gdma_queue *queue, + const struct gdma_queue_spec *spec) + struct gdma_irq_context *gic; + +struct gdma_context *gc;
Why the empty line?
drivers/net/ethernet/microsoft/mana/gdma_main.c line 652
Quoted 8 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +8
-0+ queue =kzalloc (sizeof (*queue),GFP_KERNEL ); +if (!queue) +return -ENOMEM ; + + gmi = &queue->mem_info; + err =mana_gd_alloc_memory (gc, spec->queue_size, gmi); +if (err) +return err;
Leaks the memory from 'queue'?
Same code in mana_gd_create_mana_eq(), ...wq_cq(), etc.
Quoted 26 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +26
-0+int mana_do_attach (struct net_device *ndev,enum mana_attach_caller caller) +{ +struct mana_port_context *apc =netdev_priv (ndev); +struct gdma_dev *gd = apc->ac->gdma_dev; +u32 max_txq, max_rxq, max_queues; +int port_idx = apc->port_idx; +u32 num_indirect_entries; +int err; + +if (caller ==MANA_OPEN ) + goto start_open; + + err =mana_init_port_context (apc); +if (err) +return err; + + err =mana_query_vport_cfg (apc, port_idx, &max_txq, &max_rxq, + &num_indirect_entries); +if (err) { +netdev_err (ndev,"Failed to query info for vPort 0\n" ); + goto reset_apc; + } + + max_queues =min_t (u32, max_txq, max_rxq); +if (apc->max_queues > max_queues) + apc->max_queues = max_queues;
drivers/net/ethernet/microsoft/mana/mana_en.c line 1645
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +10
-0+ +if (apc->num_queues > apc->max_queues) + apc->num_queues = apc->max_queues; + +memcpy (ndev->dev_addr, apc->mac_addr,ETH_ALEN ); + +if (caller ==MANA_PROBE ) +return 0 ; + +start_open:
Why keep this as a single function, there is no overlap between what's done for OPEN and PROBE, it seems.
Similarly detach should probably be split into clearly distinct parts.
Quoted 67 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +67
-0+ err =mana_create_eq (apc); +if (err) + goto reset_apc; + + err =mana_create_vport (apc, ndev); +if (err) + goto destroy_eq; + + err =netif_set_real_num_tx_queues (ndev, apc->num_queues); +if (err) + goto destroy_vport; + + err =mana_add_rx_queues (apc, ndev); +if (err) + goto destroy_vport; + + apc->rss_state = apc->num_queues >1 ?TRI_STATE_TRUE :TRI_STATE_FALSE ; + + err =netif_set_real_num_rx_queues (ndev, apc->num_queues); +if (err) + goto destroy_vport; + +mana_rss_table_init (apc); + + err =mana_config_rss (apc,TRI_STATE_TRUE , true, true); +if (err) + goto destroy_vport; + +return 0 ; + +destroy_vport: +mana_destroy_vport (apc); +destroy_eq: +mana_destroy_eq (gd->gdma_context, apc); +reset_apc: +if (caller ==MANA_OPEN ) +return err; +kfree (apc->rxqs); + apc->rxqs =NULL ; +return err; +} + +int mana_attach (struct net_device *ndev) +{ +struct mana_port_context *apc =netdev_priv (ndev); +int err; + +ASSERT_RTNL (); + + err =mana_do_attach (ndev,MANA_ATTACH ); +if (err) +return err; + +netif_device_attach (ndev); + + apc->port_is_up = apc->port_st_save; + +/* Ensure port state updated before txq state */ +smp_wmb (); + +if (apc->port_is_up) { +netif_carrier_on (ndev); +netif_tx_wake_all_queues (ndev); + } + +return 0 ; +}
Dexuan Cui
maintainerQuoted 8 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, April 15, 2021 10:44 AM
...drivers/net/ethernet/microsoft/mana/gdma_main.c line 131
Quoted 2 lines · On Wed, 14 Apr 2021 22:45:19 -0700 Dexuan Cui wrote:
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +2
-0+ buf =dma_alloc_coherent (gmi->dev, length, &dma_handle, +GFP_KERNEL | __GFP_ZERO);No need for
GFP_ZERO,dma_alloc_coherent()zeroes the memory these days.
Yes, indeed. Will remove __GFP_ZERO.
Quoted 9 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c line 418
Quoted 7 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +5
-0+static int mana_gd_register_irq(struct gdma_queue *queue, + const struct gdma_queue_spec *spec) + struct gdma_irq_context *gic; + +struct gdma_context *gc;Why the empty line?
No good reason. Will remove this line. I'll check the whole patch for similar issues.
Quoted 11 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c line 652
Quoted 9 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c new file +8
-0+ queue =kzalloc (sizeof (*queue),GFP_KERNEL ); +if (!queue) +return -ENOMEM ; + + gmi = &queue->mem_info; + err =mana_gd_alloc_memory (gc, spec->queue_size, gmi); +if (err) +return err;Leaks the memory from 'queue'?
Sorry. This should be a bug I introduced when moving arouond some code.
Quoted 1 line
Same code in
mana_gd_create_mana_eq(), ...wq_cq(), etc.
Will fix all of them, and check for the code similar issues.
Quoted 41 lines
Quoted 1 line
+int mana_do_attach(struct
net_device*ndev, enummana_attach_callercaller)
Quoted 25 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +25
-0+{ +struct mana_port_context *apc =netdev_priv (ndev); +struct gdma_dev *gd = apc->ac->gdma_dev; +u32 max_txq, max_rxq, max_queues; +int port_idx = apc->port_idx; +u32 num_indirect_entries; +int err; + +if (caller ==MANA_OPEN ) + goto start_open; + + err =mana_init_port_context (apc); +if (err) +return err; + + err =mana_query_vport_cfg (apc, port_idx, &max_txq, &max_rxq, + &num_indirect_entries); +if (err) { +netdev_err (ndev,"Failed to query info for vPort 0\n" ); + goto reset_apc; + } + + max_queues =min_t (u32, max_txq, max_rxq); +if (apc->max_queues > max_queues) + apc->max_queues = max_queues;drivers/net/ethernet/microsoft/mana/mana_en.c line 1645
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +10
-0+ +if (apc->num_queues > apc->max_queues) + apc->num_queues = apc->max_queues; + +memcpy (ndev->dev_addr, apc->mac_addr,ETH_ALEN ); + +if (caller ==MANA_PROBE ) +return 0 ; + +start_open:Why keep this as a single function, there is no overlap between what's done for OPEN and PROBE, it seems.
Quoted 1 line
Similarly detach should probably be split into clearly distinct parts.
Will improve the code. Thanks for the suggestion!
Thanks,
Dexuan
Quoted 21 lines · On Wed, 14 Apr 2021 22:45:19 -0700 Dexuan Cui <[email protected]> wrote:
drivers/net/ethernet/microsoft/mana/mana_en.c new file +21
-0+static int mana_query_vport_cfg (struct mana_port_context *apc,u32 vport_index, +u32 *max_sq,u32 *max_rq,u32 *num_indir_entry) +{ +struct mana_query_vport_cfg_resp resp = {}; +struct mana_query_vport_cfg_req req = {}; +int err; + +mana_gd_init_req_hdr (&req.hdr,MANA_QUERY_VPORT_CONFIG , +sizeof (req),sizeof (resp)); + + req.vport_index = vport_index; + + err =mana_send_request (apc->ac, &req,sizeof (req), &resp, +sizeof (resp)); +if (err) +return err; + + err =mana_verify_resp_hdr (&resp.hdr,MANA_QUERY_VPORT_CONFIG , +sizeof (resp)); +if (err) +return err;
drivers/net/ethernet/microsoft/mana/mana_en.c line 556
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +10
-0+ +if (resp.hdr.status) +return -EPROTO ; + + *max_sq = resp.max_num_sq; + *max_rq = resp.max_num_rq; + *num_indir_entry = resp.num_indirection_ent; + + apc->port_handle = resp.vport; +memcpy (apc->mac_addr, resp.mac_addr,ETH_ALEN );
You could use ether_addr_copy here.
Quoted 21 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +21
-0+int mana_do_attach (struct net_device *ndev,enum mana_attach_caller caller) +{ +struct mana_port_context *apc =netdev_priv (ndev); +struct gdma_dev *gd = apc->ac->gdma_dev; +u32 max_txq, max_rxq, max_queues; +int port_idx = apc->port_idx; +u32 num_indirect_entries; +int err; + +if (caller ==MANA_OPEN ) + goto start_open; + + err =mana_init_port_context (apc); +if (err) +return err; + + err =mana_query_vport_cfg (apc, port_idx, &max_txq, &max_rxq, + &num_indirect_entries); +if (err) { +netdev_err (ndev,"Failed to query info for vPort 0\n" ); + goto reset_apc;
drivers/net/ethernet/microsoft/mana/mana_en.c line 1640
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +10
-0+ } + + max_queues =min_t (u32, max_txq, max_rxq); +if (apc->max_queues > max_queues) + apc->max_queues = max_queues; + +if (apc->num_queues > apc->max_queues) + apc->num_queues = apc->max_queues; + +memcpy (ndev->dev_addr, apc->mac_addr,ETH_ALEN );
And here use ether_addr_copy().
Haiyang Zhang
maintainerQuoted 81 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, April 15, 2021 5:08 PM
To: Dexuan Cui <[email protected]>
Cc: [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; [email protected]; Wei Liu <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Shachar Raindel <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v6 net-next] net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)Quoted 1 line · On Wed, 14 Apr 2021 22:45:19 -0700 Dexuan Cui <[email protected]> wrote:
+static int mana_query_vport_cfg(struct
mana_port_context*apc, u32
vport_index,Review
Quoted 1 line
(quoted diff) +1
-0+ u32 *max_sq, u32 *max_rq, u32
*num_indir_entry) {Quoted 5 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +5
-0+struct mana_query_vport_cfg_resp resp = {}; +struct mana_query_vport_cfg_req req = {}; +int err; + + mana_gd_init_req_hdr(&req.hdr, MANA_QUERY_VPORT_CONFIG,drivers/net/ethernet/microsoft/mana/mana_en.c
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +10
-0+ sizeof(req), sizeof(resp)); + + req.vport_index = vport_index; + + err =mana_send_request (apc->ac, &req,sizeof (req), &resp, +sizeof (resp)); +if (err) +return err; + + err = mana_verify_resp_hdr(&resp.hdr,
MANA_QUERY_VPORT_CONFIG,drivers/net/ethernet/microsoft/mana/mana_en.c line 556
Quoted 13 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +13
-0+ sizeof(resp)); +if (err) +return err; + +if (resp.hdr.status) +return -EPROTO ; + + *max_sq = resp.max_num_sq; + *max_rq = resp.max_num_rq; + *num_indir_entry = resp.num_indirection_ent; + + apc->port_handle = resp.vport; +memcpy (apc->mac_addr, resp.mac_addr,ETH_ALEN );You could use
ether_addr_copyhere.Quoted 25 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +25
-0+int mana_do_attach (struct net_device *ndev,enum mana_attach_caller +caller) { +struct mana_port_context *apc =netdev_priv (ndev); +struct gdma_dev *gd = apc->ac->gdma_dev; +u32 max_txq, max_rxq, max_queues; +int port_idx = apc->port_idx; +u32 num_indirect_entries; +int err; + +if (caller ==MANA_OPEN ) + goto start_open; + + err =mana_init_port_context (apc); +if (err) +return err; + + err =mana_query_vport_cfg (apc, port_idx, &max_txq, &max_rxq, + &num_indirect_entries); +if (err) { +netdev_err (ndev,"Failed to query info for vPort 0\n" ); + goto reset_apc; + } + + max_queues =min_t (u32, max_txq, max_rxq); +if (apc->max_queues > max_queues)
Quoted 8 lines
drivers/net/ethernet/microsoft/mana/mana_en.c line 1640
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +6
-0+ apc->max_queues = max_queues; + +if (apc->num_queues > apc->max_queues) + apc->num_queues = apc->max_queues; + +memcpy (ndev->dev_addr, apc->mac_addr,ETH_ALEN );And here use
ether_addr_copy().
Thanks, I will update these.
- Haiyang
Quoted 24 lines · On Wed, 14 Apr 2021 22:45:19 -0700 Dexuan Cui <[email protected]> wrote:
drivers/net/ethernet/microsoft/mana/mana_en.c new file +24
-0+static int mana_probe_port (struct mana_context *ac,int port_idx, +struct net_device **ndev_storage) +{ +struct gdma_context *gc = ac->gdma_dev->gdma_context; +struct mana_port_context *apc; +struct net_device *ndev; +int err; + + ndev =alloc_etherdev_mq (sizeof (struct mana_port_context ), + gc->max_num_queues); +if (!ndev) +return -ENOMEM ; + + *ndev_storage = ndev; + + apc =netdev_priv (ndev); + apc->ac = ac; + apc->ndev = ndev; + apc->max_queues = gc->max_num_queues; + apc->num_queues =min_t (uint, gc->max_num_queues,MANA_MAX_NUM_QUEUES ); + apc->port_handle =INVALID_MANA_HANDLE ; + apc->port_idx = port_idx; + + ndev->netdev_ops = &mana_devops;
drivers/net/ethernet/microsoft/mana/mana_en.c line 1807
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c new file +10
-0+ ndev->ethtool_ops = &mana_ethtool_ops; + ndev->mtu =ETH_DATA_LEN ; + ndev->max_mtu = ndev->mtu; + ndev->min_mtu = ndev->mtu; + ndev->needed_headroom =MANA_HEADROOM ; +SET_NETDEV_DEV (ndev, gc->dev); + +netif_carrier_off (ndev); + +get_random_bytes (apc->hashkey,MANA_HASH_KEY_SIZE );
Current practice for network drivers is to use netdev_rss_key_fill() for this.
Dexuan Cui
maintainerQuoted 8 lines
From: Stephen Hemminger <[email protected]>
Sent: Thursday, April 15, 2021 2:15 PMdrivers/net/ethernet/microsoft/mana/mana_en.c line 1807
Quoted 4 lines
...
drivers/net/ethernet/microsoft/mana/mana_en.c new file +3
-0+netif_carrier_off (ndev); + +get_random_bytes (apc->hashkey,MANA_HASH_KEY_SIZE );Current practice for network drivers is to use
netdev_rss_key_fill()for this.
Will change to netdev_rss_key_fill(). Thanks!