bnxt_en: Update for net-next.
Michael Chan
maintainercover bnxt_en: Update for net-next.
Misc. updates including updated firmware interface, some additional port statistics, a new IRQ assignment scheme for the RDMA driver, support for VF trust, and other changes and improvements for SRIOV.
Michael Chan (12):
bnxt_en: Update firmware interface to 1.9.1.15.
bnxt_en: Adjust default rings for multi-port NICs.
bnxt_en: Use a dedicated VNIC mode for RDMA.
bnxt_en: Check max_tx_scheduler_inputs value from firmware.
bnxt_en: Improve resource accounting for SRIOV.
bnxt_en: Improve valid bit checking in firmware response message.
bnxt_en: Improve ring allocation logic.
bnxt_en: Change IRQ assignment for RDMA driver.
bnxt_en: Add IRQ remapping logic.
bnxt_en: Refactor bnxt_need_reserve_rings().
bnxt_en: Reserve completion rings and MSIX for bnxt_re RDMA driver.
bnxt_en: Add ULP calls to stop and restart IRQs.
Scott Branden (1):
bnxt_en: fix clear flags in ethtool reset handling
Vasundhara Volam (3):
bnxt_en: Add support for ndo_set_vf_trust
bnxt_en: Include additional hardware port statistics in ethtool -S.
bnxt_en: Add extended port statistics support
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 339 +++++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 21 +- drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.h | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 56 +++- drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 289 ++++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 61 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h | 3 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 144 ++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 22 +- 9 files changed, 706 insertions(+), 234 deletions(-)
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 1/16 bnxt_en: Update firmware interface to 1.9.1.15.
Minor changes, such as new extended port statistics.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.h | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 289 +++++++++++++++++--------- 4 files changed, 210 insertions(+), 103 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +9 -6
@@ -3577,9 +3577,13 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp) FUNC_DRV_RGTR_REQ_ENABLES_VER); req.os_type =cpu_to_le16 (FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX ); - req.ver_maj =DRV_VER_MAJ ; - req.ver_min =DRV_VER_MIN ; - req.ver_upd =DRV_VER_UPD ; + req.flags =cpu_to_le32 (FUNC_DRV_RGTR_REQ_FLAGS_16BIT_VER_MODE ); + req.ver_maj_8b =DRV_VER_MAJ ; + req.ver_min_8b =DRV_VER_MIN ; + req.ver_upd_8b =DRV_VER_UPD ; + req.ver_maj =cpu_to_le16 (DRV_VER_MAJ ); + req.ver_min =cpu_to_le16 (DRV_VER_MIN ); + req.ver_upd =cpu_to_le16 (DRV_VER_UPD );if (BNXT_PF (bp)) {u32 data[8 ];
@@ -5418,10 +5422,9 @@ static int bnxt_hwrm_set_cache_line_size(struct bnxt *bp, int size)bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_FUNC_CFG ,-1 ,-1 ); req.fid =cpu_to_le16 (0xffff ); req.enables =cpu_to_le32 (FUNC_CFG_REQ_ENABLES_CACHE_LINESIZE ); - req.cache_linesize =FUNC_QCFG_RESP_CACHE_LINESIZE_CACHE_LINESIZE_64 ; + req.options =FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_64 ;if (size ==128 ) - req.cache_linesize = -FUNC_QCFG_RESP_CACHE_LINESIZE_CACHE_LINESIZE_128 ; + req.options =FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128 ; rc =hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT );if (rc)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -2
@@ -12,11 +12,11 @@#define BNXT_H #define DRV_MODULE_NAME "bnxt_en" -#define DRV_MODULE_VERSION "1.9.0" +#define DRV_MODULE_VERSION "1.9.1"#define DRV_VER_MAJ 1#define DRV_VER_MIN 9 -#define DRV_VER_UPD 0 +#define DRV_VER_UPD 1#include <linux/interrupt.h> #include <linux/rhashtable.h>
drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.h +3 -2
@@ -1,7 +1,7 @@/* Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2014-2016 Broadcom Corporation -* Copyright (c) 2016-2017 Broadcom Limited +* Copyright (c) 2016-2018 Broadcom Limited * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -34,7 +34,8 @@ struct bnxt_cos2bw_cfg { };#define BNXT_LLQ (q_profile) \ - ((q_profile) == QUEUE_QPORTCFG_RESP_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS) + ((q_profile) == \ + QUEUE_QPORTCFG_RESP_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE)#define HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL 0x0300
drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h +196 -93
454 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 2/16 bnxt_en: Adjust default rings for multi-port NICs.
In reply to Michael ChanChange the default ring logic to select default number of rings to be up to 8 per port if the default rings x NIC ports <= total CPUs.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +9 -3
@@ -8393,9 +8393,15 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)if (sh) bp->flags |=BNXT_FLAG_SHARED_RINGS ; dflt_rings =netif_get_num_default_rss_queues (); -/* Reduce default rings to reduce memory usage on multi-port cards */ -if (bp->port_count >1 ) - dflt_rings =min_t (int, dflt_rings,4 ); +/* Reduce default rings on multi-port cards so that total default +* rings do not exceed CPU count. +*/ +if (bp->port_count >1 ) { +int max_rings = +max_t (int,num_online_cpus () / bp->port_count,1 ); + + dflt_rings =min_t (int, dflt_rings, max_rings); + } rc =bnxt_get_dflt_rings (bp, &max_rx_rings, &max_tx_rings, sh);if (rc)return rc;
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 3/16 bnxt_en: Use a dedicated VNIC mode for RDMA.
In reply to Michael ChanIf the RDMA driver is registered, use a new VNIC mode that allows RDMA traffic to be seen on the netdev in promiscuous mode.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ++++++++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +14 -4
@@ -4002,6 +4002,13 @@ static int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, u16 vnic_id, u16 ctx_idx)return rc; } +static u32 bnxt_get_roce_vnic_mode (struct bnxt *bp) +{ +if (bp->flags &BNXT_FLAG_ROCE_MIRROR_CAP ) +return VNIC_CFG_REQ_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_MODE ; +return VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE ; +} +int bnxt_hwrm_vnic_cfg (struct bnxt *bp,u16 vnic_id) {unsigned int ring =0 , grp_idx;
@@ -4057,8 +4064,7 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)if ((bp->flags &BNXT_FLAG_STRIP_VLAN ) || def_vlan) req.flags |=cpu_to_le32 (VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE );if (!vnic_id &&bnxt_ulp_registered (bp->edev,BNXT_ROCE_ULP )) - req.flags |= -cpu_to_le32 (VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE ); + req.flags |=cpu_to_le32 (bnxt_get_roce_vnic_mode (bp));return hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); }
@@ -4139,9 +4145,13 @@ static int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)mutex_lock (&bp->hwrm_cmd_lock); rc =_hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT );if (!rc) { -if (resp->flags & -cpu_to_le32 (VNIC_QCAPS_RESP_FLAGS_RSS_DFLT_CR_CAP )) +u32 flags =le32_to_cpu (resp->flags); + +if (flags &VNIC_QCAPS_RESP_FLAGS_RSS_DFLT_CR_CAP ) bp->flags |=BNXT_FLAG_NEW_RSS_CAP ; +if (flags & +VNIC_QCAPS_RESP_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_CAP ) + bp->flags |=BNXT_FLAG_ROCE_MIRROR_CAP ; }mutex_unlock (&bp->hwrm_cmd_lock);return rc;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1151,6 +1151,7 @@ struct bnxt {#define BNXT_FLAG_FW_DCBX_AGENT 0x800000#define BNXT_FLAG_CHIP_NITRO_A0 0x1000000#define BNXT_FLAG_DIM 0x2000000 +#define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000#define BNXT_FLAG_NEW_RM 0x8000000#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 4/16 bnxt_en: fix clear flags in ethtool reset handling
In reply to Michael ChanFrom: Scott Branden <[email protected]>
Clear flags when reset command processed successfully for components specified.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +6 -2
@@ -2535,16 +2535,20 @@ static int bnxt_reset(struct net_device *dev, u32 *flags)return -EOPNOTSUPP ; rc =bnxt_firmware_reset (dev,BNXT_FW_RESET_CHIP ); -if (!rc) +if (!rc) {netdev_info (dev,"Reset request successful. Reload driver to complete reset\n" ); + *flags =0 ; + } }else if (*flags ==ETH_RESET_AP ) {/* This feature is not supported in older firmware versions */ if (bp->hwrm_spec_code <0x10803 )return -EOPNOTSUPP ; rc =bnxt_firmware_reset (dev,BNXT_FW_RESET_AP ); -if (!rc) +if (!rc) {netdev_info (dev,"Reset Application Processor request successful.\n" ); + *flags =0 ; + } }else { rc = -EINVAL ; }
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 5/16 bnxt_en: Add support for ndo_set_vf_trust
In reply to Michael ChanFrom: Vasundhara Volam <[email protected]>
Trusted VFs are allowed to modify MAC address, even when PF has assigned one.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 41 ++++++++++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h | 3 +- 4 files changed, 37 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -0
@@ -8206,6 +8206,7 @@ static int bnxt_swdev_port_attr_get(struct net_device *dev, .ndo_set_vf_rate = bnxt_set_vf_bw, .ndo_set_vf_link_state = bnxt_set_vf_link_state, .ndo_set_vf_spoofchk = bnxt_set_vf_spoofchk, + .ndo_set_vf_trust = bnxt_set_vf_trust,#endif #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = bnxt_poll_controller,
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -815,6 +815,7 @@ struct bnxt_vf_info {#define BNXT_VF_SPOOFCHK 0x2#define BNXT_VF_LINK_FORCED 0x4#define BNXT_VF_LINK_UP 0x8 +#define BNXT_VF_TRUST 0x10u32 func_flags;/* func cfg flags */ u32 min_tx_rate;u32 max_tx_rate;
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +33 -8
88 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h +2 -1
@@ -1,7 +1,7 @@/* Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2014-2016 Broadcom Corporation -* Copyright (c) 2016-2017 Broadcom Limited +* Copyright (c) 2016-2018 Broadcom Limited * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@int bnxt_set_vf_bw (struct net_device *,int ,int ,int );int bnxt_set_vf_link_state (struct net_device *,int ,int );int bnxt_set_vf_spoofchk (struct net_device *,int ,bool ); +int bnxt_set_vf_trust (struct net_device *dev,int vf_id,bool trust);int bnxt_sriov_configure (struct pci_dev *pdev,int num_vfs);void bnxt_sriov_disable (struct bnxt *);void bnxt_hwrm_exec_fwd_req (struct bnxt *);
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 6/16 bnxt_en: Include additional hardware port statistics in ethtool -S.
In reply to Michael ChanFrom: Vasundhara Volam <[email protected]>
Include additional hardware port statistics in ethtool -S, which are useful for debugging.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +5 -0
@@ -181,6 +181,8 @@ static int bnxt_set_coalesce(struct net_device *dev,BNXT_RX_STATS_ENTRY (rx_bytes),BNXT_RX_STATS_ENTRY (rx_runt_bytes),BNXT_RX_STATS_ENTRY (rx_runt_frames), +BNXT_RX_STATS_ENTRY (rx_stat_discard), +BNXT_RX_STATS_ENTRY (rx_stat_err),BNXT_TX_STATS_ENTRY (tx_64b_frames), BNXT_TX_STATS_ENTRY(tx_65b_127b_frames),
@@ -216,6 +218,9 @@ static int bnxt_set_coalesce(struct net_device *dev,BNXT_TX_STATS_ENTRY (tx_eee_lpi_duration),BNXT_TX_STATS_ENTRY (tx_total_collisions),BNXT_TX_STATS_ENTRY (tx_bytes), +BNXT_TX_STATS_ENTRY (tx_xthol_frames), +BNXT_TX_STATS_ENTRY (tx_stat_discard), + BNXT_TX_STATS_ENTRY(tx_stat_error), };#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr)
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 7/16 bnxt_en: Add extended port statistics support
In reply to Michael ChanFrom: Vasundhara Volam <[email protected]>
Gather periodic extended port statistics, if the device is PF and link is up.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 45 ++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 6 +++ drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 32 ++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +43 -2
@@ -3059,12 +3059,21 @@ static void bnxt_free_stats(struct bnxt *bp)u32 size, i;struct pci_dev *pdev = bp->pdev; + bp->flags &= ~BNXT_FLAG_PORT_STATS ; + bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT ; +if (bp->hw_rx_port_stats) {dma_free_coherent (&pdev->dev, bp->hw_port_stats_size, bp->hw_rx_port_stats, bp->hw_rx_port_stats_map); bp->hw_rx_port_stats =NULL ; - bp->flags &= ~BNXT_FLAG_PORT_STATS ; + } + +if (bp->hw_rx_port_stats_ext) { +dma_free_coherent (&pdev->dev,sizeof (struct rx_port_stats_ext ), + bp->hw_rx_port_stats_ext, + bp->hw_rx_port_stats_ext_map); + bp->hw_rx_port_stats_ext =NULL ; }if (!bp->bnapi)
@@ -3120,6 +3129,21 @@ static int bnxt_alloc_stats(struct bnxt *bp) bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map +sizeof (struct rx_port_stats ) +512 ; bp->flags |=BNXT_FLAG_PORT_STATS ; + +/* Display extended statistics only if FW supports it */ +if (bp->hwrm_spec_code <0x10804 || + bp->hwrm_spec_code ==0x10900 ) +return 0 ; + + bp->hw_rx_port_stats_ext = +dma_zalloc_coherent (&pdev->dev, +sizeof (struct rx_port_stats_ext ), + &bp->hw_rx_port_stats_ext_map, +GFP_KERNEL ); +if (!bp->hw_rx_port_stats_ext) +return 0 ; + + bp->flags |=BNXT_FLAG_PORT_STATS_EXT ; }return 0 ; }
@@ -5340,6 +5364,21 @@ static int bnxt_hwrm_port_qstats(struct bnxt *bp)return rc; } +static int bnxt_hwrm_port_qstats_ext (struct bnxt *bp) +{ +struct hwrm_port_qstats_ext_input req = {0 }; +struct bnxt_pf_info *pf = &bp->pf; + +if (!(bp->flags &BNXT_FLAG_PORT_STATS_EXT )) +return 0 ; + +bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_PORT_QSTATS_EXT ,-1 ,-1 ); + req.port_id =cpu_to_le16 (pf->port_id); + req.rx_stat_size =cpu_to_le16 (sizeof (struct rx_port_stats_ext )); + req.rx_stat_host_addr =cpu_to_le64 (bp->hw_rx_port_stats_ext_map); +return hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); +} +static void bnxt_hwrm_free_tunnel_ports (struct bnxt *bp) {if (bp->vxlan_port_cnt) {
@@ -7491,8 +7530,10 @@ static void bnxt_sp_task(struct work_struct *work)bnxt_hwrm_tunnel_dst_port_free ( bp,TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE ); } -if (test_and_clear_bit (BNXT_PERIODIC_STATS_SP_EVENT , &bp->sp_event)) +if (test_and_clear_bit (BNXT_PERIODIC_STATS_SP_EVENT , &bp->sp_event)) {bnxt_hwrm_port_qstats (bp); +bnxt_hwrm_port_qstats_ext (bp); + }if (test_and_clear_bit (BNXT_LINK_CHNG_SP_EVENT , &bp->sp_event)) {int rc;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +6 -0
@@ -1154,6 +1154,7 @@ struct bnxt {#define BNXT_FLAG_DIM 0x2000000#define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000#define BNXT_FLAG_NEW_RM 0x8000000 +#define BNXT_FLAG_PORT_STATS_EXT 0x10000000#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ BNXT_FLAG_RFS | \
@@ -1273,8 +1274,10 @@ struct bnxt {struct rx_port_stats *hw_rx_port_stats;struct tx_port_stats *hw_tx_port_stats; +struct rx_port_stats_ext *hw_rx_port_stats_ext;dma_addr_t hw_rx_port_stats_map;dma_addr_t hw_tx_port_stats_map; +dma_addr_t hw_rx_port_stats_ext_map;int hw_port_stats_size;u16 hwrm_max_req_len;
@@ -1385,6 +1388,9 @@ struct bnxt { ((offsetof(struct tx_port_stats , counter) + \ sizeof(struct rx_port_stats) + 512) / 8) +#define BNXT_RX_STATS_EXT_OFFSET (counter) \ + (offsetof(struct rx_port_stats_ext, counter) / 8) +#define I2C_DEV_ADDR_A0 0xa0#define I2C_DEV_ADDR_A2 0xa2#define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +32 -0
@@ -137,6 +137,9 @@ static int bnxt_set_coalesce(struct net_device *dev,#define BNXT_TX_STATS_ENTRY (counter) \ { BNXT_TX_STATS_OFFSET(counter), __stringify(counter) } +#define BNXT_RX_STATS_EXT_ENTRY (counter) \ + { BNXT_RX_STATS_EXT_OFFSET(counter), __stringify(counter) } + static const struct { long offset; char string[ETH_GSTRING_LEN];
@@ -223,7 +226,19 @@ static int bnxt_set_coalesce(struct net_device *dev, BNXT_TX_STATS_ENTRY(tx_stat_error), }; +static const struct { +long offset; +char string[ETH_GSTRING_LEN ]; +} bnxt_port_stats_ext_arr[] = { +BNXT_RX_STATS_EXT_ENTRY (link_down_events), +BNXT_RX_STATS_EXT_ENTRY (continuous_pause_events), +BNXT_RX_STATS_EXT_ENTRY (resume_pause_events), +BNXT_RX_STATS_EXT_ENTRY (continuous_roce_pause_events), +BNXT_RX_STATS_EXT_ENTRY (resume_roce_pause_events), +}; +#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr) +#define BNXT_NUM_PORT_STATS_EXT ARRAY_SIZE(bnxt_port_stats_ext_arr)static int bnxt_get_num_stats (struct bnxt *bp) {
@@ -232,6 +247,9 @@ static int bnxt_get_num_stats(struct bnxt *bp)if (bp->flags &BNXT_FLAG_PORT_STATS ) num_stats +=BNXT_NUM_PORT_STATS ; +if (bp->flags &BNXT_FLAG_PORT_STATS_EXT ) + num_stats +=BNXT_NUM_PORT_STATS_EXT ; +return num_stats; }
@@ -279,6 +297,14 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, bnxt_port_stats_arr[i].offset)); } } +if (bp->flags &BNXT_FLAG_PORT_STATS_EXT ) { +__le64 *port_stats_ext = (__le64 *)bp->hw_rx_port_stats_ext; + +for (i =0 ; i <BNXT_NUM_PORT_STATS_EXT ; i++, j++) { + buf[j] =le64_to_cpu (*(port_stats_ext + + bnxt_port_stats_ext_arr[i].offset)); + } + } }static void bnxt_get_strings (struct net_device *dev,u32 stringset,u8 *buf)
@@ -339,6 +365,12 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf) buf +=ETH_GSTRING_LEN ; } } +if (bp->flags &BNXT_FLAG_PORT_STATS_EXT ) { +for (i =0 ; i <BNXT_NUM_PORT_STATS_EXT ; i++) { +strcpy (buf, bnxt_port_stats_ext_arr[i].string); + buf +=ETH_GSTRING_LEN ; + } + }break ;case ETH_SS_TEST :if (bp->num_tests)
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 8/16 bnxt_en: Check max_tx_scheduler_inputs value from firmware.
In reply to Michael ChanWhen checking for the maximum pre-set TX channels for ethtool -l, we need to check the current max_tx_scheduler_inputs parameter from firmware. This parameter specifies the max input for the internal QoS nodes currently available to this function. The function's TX rings will be capped by this parameter. By adding this logic, we provide a more accurate pre-set max TX channels to the user.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
@@ -5093,7 +5093,7 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)return rc; } -static int bnxt_hwrm_func_resc_qcaps (struct bnxt *bp) +int bnxt_hwrm_func_resc_qcaps (struct bnxt *bp,bool all) {struct hwrm_func_resource_qcaps_output *resp = bp->hwrm_cmd_resp_addr;struct hwrm_func_resource_qcaps_input req = {0 };
@@ -5110,6 +5110,10 @@ static int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp) goto hwrm_func_resc_qcaps_exit; } + hw_resc->max_tx_sch_inputs =le16_to_cpu (resp->max_tx_scheduler_inputs); +if (!all) + goto hwrm_func_resc_qcaps_exit; + hw_resc->min_rsscos_ctxs =le16_to_cpu (resp->min_rsscos_ctx); hw_resc->max_rsscos_ctxs =le16_to_cpu (resp->max_rsscos_ctx); hw_resc->min_cp_rings =le16_to_cpu (resp->min_cmpl_rings);
@@ -5216,7 +5220,7 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)if (rc)return rc;if (bp->hwrm_spec_code >=0x10803 ) { - rc =bnxt_hwrm_func_resc_qcaps (bp); + rc =bnxt_hwrm_func_resc_qcaps (bp, true);if (!rc) bp->flags |=BNXT_FLAG_NEW_RM ; }
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -786,6 +786,7 @@ struct bnxt_hw_resc {u16 min_tx_rings;u16 max_tx_rings;u16 resv_tx_rings; +u16 max_tx_sch_inputs;u16 min_rx_rings;u16 max_rx_rings;u16 resv_rx_rings;
@@ -1456,6 +1457,7 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,int bnxt_hwrm_set_link_setting (struct bnxt *,bool ,bool );int bnxt_hwrm_alloc_wol_fltr (struct bnxt *bp);int bnxt_hwrm_free_wol_fltr (struct bnxt *bp); +int bnxt_hwrm_func_resc_qcaps (struct bnxt *bp,bool all);int bnxt_hwrm_fw_set_time (struct bnxt *);int bnxt_open_nic (struct bnxt *,bool ,bool );int bnxt_half_open_nic (struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +11 -0
@@ -425,15 +425,26 @@ static void bnxt_get_channels(struct net_device *dev, struct ethtool_channels *channel) {struct bnxt *bp =netdev_priv (dev); +struct bnxt_hw_resc *hw_resc = &bp->hw_resc;int max_rx_rings, max_tx_rings, tcs; +int max_tx_sch_inputs; + +/* Get the most up-to-date max_tx_sch_inputs. */ +if (bp->flags &BNXT_FLAG_NEW_RM ) +bnxt_hwrm_func_resc_qcaps (bp, false); + max_tx_sch_inputs = hw_resc->max_tx_sch_inputs;bnxt_get_max_rings (bp, &max_rx_rings, &max_tx_rings, true); +if (max_tx_sch_inputs) + max_tx_rings =min_t (int, max_tx_rings, max_tx_sch_inputs); channel->max_combined =min_t (int, max_rx_rings, max_tx_rings);if (bnxt_get_max_rings (bp, &max_rx_rings, &max_tx_rings, false)) { max_rx_rings =0 ; max_tx_rings =0 ; } +if (max_tx_sch_inputs) + max_tx_rings =min_t (int, max_tx_rings, max_tx_sch_inputs); tcs =netdev_get_num_tc (dev);if (tcs >1 )
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 9/16 bnxt_en: Improve resource accounting for SRIOV.
In reply to Michael ChanWhen VFs are created, the current code subtracts the maximum VF resources from the PF's pool. This under-estimates the resources remaining in the PF pool. Instead, we should subtract the minimum VF resources. The VF minimum resources are guaranteed to the VFs and only these should be subtracted from the PF's pool.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +8 -10
@@ -510,18 +510,16 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs) }mutex_unlock (&bp->hwrm_cmd_lock);if (pf->active_vfs) { -u16 n =1 ; +u16 n = pf->active_vfs; -if (pf->vf_resv_strategy !=BNXT_VF_RESV_STRATEGY_MINIMAL ) - n = pf->active_vfs; - - hw_resc->max_tx_rings -= vf_tx_rings * n; - hw_resc->max_rx_rings -= vf_rx_rings * n; - hw_resc->max_hw_ring_grps -= vf_ring_grps * n; - hw_resc->max_cp_rings -= vf_cp_rings * n; + hw_resc->max_tx_rings -=le16_to_cpu (req.min_tx_rings) * n; + hw_resc->max_rx_rings -=le16_to_cpu (req.min_rx_rings) * n; + hw_resc->max_hw_ring_grps -=le16_to_cpu (req.min_hw_ring_grps) * + n; + hw_resc->max_cp_rings -=le16_to_cpu (req.min_cmpl_rings) * n; hw_resc->max_rsscos_ctxs -= pf->active_vfs; - hw_resc->max_stat_ctxs -= vf_stat_ctx * n; - hw_resc->max_vnics -= vf_vnics * n; + hw_resc->max_stat_ctxs -=le16_to_cpu (req.min_stat_ctx) * n; + hw_resc->max_vnics -=le16_to_cpu (req.min_vnics) * n; rc = pf->active_vfs; }
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 10/16 bnxt_en: Improve valid bit checking in firmware response message.
In reply to Michael ChanWhen firmware sends a DMA response to the driver, the last byte of the message will be set to 1 to indicate that the whole response is valid. The driver waits for the message to be valid before reading the message.
The firmware spec allows these response messages to increase in length by adding new fields to the end of these messages. The older spec's valid location may become a new field in a newer spec. To guarantee compatibility, the driver should zero the valid byte before interpreting the entire message so that any new fields not implemented by the older spec will be read as zero.
For messages that are forwarded to VFs, we need to set the length and re-instate the valid bit so the VF will see the valid response.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 ++++++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +16 -5
@@ -3422,7 +3422,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,int i, intr_process, rc, tmo_count;struct input *req = msg;u32 *data = msg; -__le32 *resp_len, *valid; +__le32 *resp_len; +u8 *valid;u16 cp_ring_id, len =0 ;struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr;u16 max_req_len =BNXT_HWRM_MAX_REQ_LEN ;
@@ -3474,6 +3475,7 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, i =0 ; tmo_count = timeout *40 ; + resp_len = bp->hwrm_cmd_resp_addr +HWRM_RESP_LEN_OFFSET ;if (intr_process) {/* Wait until hwrm response cmpl interrupt is processed */ while (bp->hwrm_intr_seq_id != HWRM_SEQ_ID_INVALID &&
@@ -3486,9 +3488,11 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, le16_to_cpu(req->req_type));return -1 ; } + len = (le32_to_cpu (*resp_len) &HWRM_RESP_LEN_MASK ) >> +HWRM_RESP_LEN_SFT ; + valid = bp->hwrm_cmd_resp_addr + len -1 ; }else {/* Check if response len is updated */ - resp_len = bp->hwrm_cmd_resp_addr +HWRM_RESP_LEN_OFFSET ;for (i =0 ; i < tmo_count; i++) { len = (le32_to_cpu (*resp_len) &HWRM_RESP_LEN_MASK ) >>HWRM_RESP_LEN_SFT ;
@@ -3504,10 +3508,12 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,return -1 ; } -/* Last word of resp contains valid bit */ - valid = bp->hwrm_cmd_resp_addr + len -4 ; +/* Last byte of resp contains valid bit */ + valid = bp->hwrm_cmd_resp_addr + len -1 ;for (i =0 ; i <5 ; i++) { -if (le32_to_cpu (*valid) &HWRM_RESP_VALID_MASK ) +/* make sure we read from updated DMA memory */ +dma_rmb (); +if (*valid)break ;udelay (1 ); }
@@ -3520,6 +3526,11 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, } } +/* Zero valid bit for compatibility. Valid bit in an older spec +* may become a new field in a newer spec. We must make sure that +* a new field not implemented by old spec will read zero. +*/ + *valid =0 ; rc =le16_to_cpu (resp->error_code);if (rc && !silent) netdev_err(bp->dev, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n",
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +2 -0
@@ -974,7 +974,9 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf)memcpy (&phy_qcfg_resp, &bp->link_info.phy_qcfg_resp,sizeof (phy_qcfg_resp));mutex_unlock (&bp->hwrm_cmd_lock); + phy_qcfg_resp.resp_len =cpu_to_le16 (sizeof (phy_qcfg_resp)); phy_qcfg_resp.seq_id = phy_qcfg_req->seq_id; + phy_qcfg_resp.valid =1 ;if (vf->flags &BNXT_VF_LINK_UP ) {/* if physical link is down, force link up on VF */
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 11/16 bnxt_en: Improve ring allocation logic.
In reply to Michael ChanCurrently, the driver code makes some assumptions about the group index and the map index of rings. This makes the code more difficult to understand and less flexible.
Improve it by adding the grp_idx and map_idx fields explicitly to the bnxt_ring_struct as a union. The grp_idx is initialized for each tx ring and rx agg ring during init. time. We do the same for the map_idx for each cmpl ring.
The grp_idx ties the tx ring to the ring group. The map_idx is the doorbell index of the ring. With this new infrastructure, we can change the ring index mapping scheme easily in the future.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 32 ++++++++++++++++--------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++++ 2 files changed, 21 insertions(+), 15 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +17 -15
@@ -2317,6 +2317,7 @@ static int bnxt_alloc_rx_rings(struct bnxt *bp)if (rc)return rc; + ring->grp_idx = i; rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask +1 ; mem_size = rxr->rx_agg_bmap_size /8 ; rxr->rx_agg_bmap =kzalloc (mem_size,GFP_KERNEL );
@@ -2389,6 +2390,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)if (rc)return rc; + ring->grp_idx = txr->bnapi->index;if (bp->tx_push_size) {dma_addr_t mapping;
@@ -2458,6 +2460,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp) rc =bnxt_alloc_ring (bp, ring);if (rc)return rc; + ring->map_idx = i; }return 0 ; }
@@ -4253,12 +4256,12 @@ static int bnxt_hwrm_ring_grp_free(struct bnxt *bp)static int hwrm_ring_alloc_send_msg (struct bnxt *bp,struct bnxt_ring_struct *ring, -u32 ring_type,u32 map_index, -u32 stats_ctx_id) +u32 ring_type,u32 map_index) {int rc =0 , err =0 ;struct hwrm_ring_alloc_input req = {0 };struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr; +struct bnxt_ring_grp_info *grp_info;u16 ring_id;bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_RING_ALLOC ,-1 ,-1 );
@@ -4280,10 +4283,10 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp,case HWRM_RING_ALLOC_TX : req.ring_type =RING_ALLOC_REQ_RING_TYPE_TX ;/* Association of transmit ring with completion ring */ - req.cmpl_ring_id = -cpu_to_le16 (bp->grp_info[map_index].cp_fw_ring_id); + grp_info = &bp->grp_info[ring->grp_idx]; + req.cmpl_ring_id =cpu_to_le16 (grp_info->cp_fw_ring_id); req.length =cpu_to_le32 (bp->tx_ring_mask +1 ); - req.stat_ctx_id =cpu_to_le32 (stats_ctx_id); + req.stat_ctx_id =cpu_to_le32 (grp_info->fw_stats_ctx); req.queue_id =cpu_to_le16 (ring->queue_id);break ;case HWRM_RING_ALLOC_RX :
@@ -4370,10 +4373,11 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)struct bnxt_napi *bnapi = bp->bnapi[i];struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; +u32 map_idx = ring->map_idx; - cpr->cp_doorbell = bp->bar1 + i *0x80 ; - rc =hwrm_ring_alloc_send_msg (bp, ring,HWRM_RING_ALLOC_CMPL , i, -INVALID_STATS_CTX_ID ); + cpr->cp_doorbell = bp->bar1 + map_idx *0x80 ; + rc =hwrm_ring_alloc_send_msg (bp, ring,HWRM_RING_ALLOC_CMPL , + map_idx);if (rc) goto err_out;BNXT_CP_DB (cpr->cp_doorbell, cpr->cp_raw_cons);
@@ -4389,11 +4393,10 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)for (i =0 ; i < bp->tx_nr_rings; i++) {struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];struct bnxt_ring_struct *ring = &txr->tx_ring_struct; -u32 map_idx = txr->bnapi->index; -u16 fw_stats_ctx = bp->grp_info[map_idx].fw_stats_ctx; +u32 map_idx = i; rc =hwrm_ring_alloc_send_msg (bp, ring,HWRM_RING_ALLOC_TX , - map_idx, fw_stats_ctx); + map_idx);if (rc) goto err_out; txr->tx_doorbell = bp->bar1 + map_idx *0x80 ;
@@ -4405,7 +4408,7 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)u32 map_idx = rxr->bnapi->index; rc =hwrm_ring_alloc_send_msg (bp, ring,HWRM_RING_ALLOC_RX , - map_idx,INVALID_STATS_CTX_ID ); + map_idx);if (rc) goto err_out; rxr->rx_doorbell = bp->bar1 + map_idx *0x80 ;
@@ -4418,13 +4421,12 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; -u32 grp_idx = rxr->bnapi->index; +u32 grp_idx = ring->grp_idx;u32 map_idx = grp_idx + bp->rx_nr_rings; rc =hwrm_ring_alloc_send_msg (bp, ring,HWRM_RING_ALLOC_AGG , - map_idx, -INVALID_STATS_CTX_ID ); + map_idx);if (rc) goto err_out;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +4 -0
@@ -573,6 +573,10 @@ struct bnxt_ring_struct {void **vmem;u16 fw_ring_id;/* Ring id filled by Chimp FW */ +union { +u16 grp_idx; +u16 map_idx;/* Used by cmpl rings */ + };u8 queue_id; };
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 12/16 bnxt_en: Change IRQ assignment for RDMA driver.
In reply to Michael ChanIn the current code, the range of MSIX vectors allocated for the RDMA driver is disjoint from the network driver. This creates a problem for the new firmware ring reservation scheme. The new scheme requires the reserved completion rings/MSIX vectors to be in a contiguous range.
Change the logic to allocate RDMA MSIX vectors to be contiguous with the vectors used by bnxt_en on new firmware using the new scheme. The new function bnxt_get_num_msix() calculates the exact number of vectors needed by both drivers.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 30 +++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 3 +++ 3 files changed, 61 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +29 -2
@@ -4720,6 +4720,21 @@ static int bnxt_hwrm_reserve_rings(struct bnxt *bp, int tx, int rx, int grp,return bnxt_hwrm_reserve_vf_rings (bp, tx, rx, grp, cp, vnic); } +static int bnxt_cp_rings_in_use (struct bnxt *bp) +{ +int cp = bp->cp_nr_rings; +int ulp_msix, ulp_base; + + ulp_msix =bnxt_get_ulp_msix_num (bp); +if (ulp_msix) { + ulp_base =bnxt_get_ulp_msix_base (bp); + cp += ulp_msix; +if ((ulp_base + ulp_msix) > cp) + cp = ulp_base + ulp_msix; + } +return cp; +} +static int bnxt_trim_rings (struct bnxt *bp,int *rx,int *tx,int max,bool shared);
@@ -5893,12 +5908,24 @@ void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs) bp->hw_resc.max_irqs = max_irqs; } +static int bnxt_get_num_msix (struct bnxt *bp) +{ +if (!(bp->flags &BNXT_FLAG_NEW_RM )) +return bnxt_get_max_func_irqs (bp); + +return bnxt_cp_rings_in_use (bp); +} +static int bnxt_init_msix (struct bnxt *bp) { -int i, total_vecs, rc =0 , min =1 ; +int i, total_vecs, max, rc =0 , min =1 ;struct msix_entry *msix_ent; - total_vecs =bnxt_get_max_func_irqs (bp); + total_vecs =bnxt_get_num_msix (bp); + max =bnxt_get_max_func_irqs (bp); +if (total_vecs > max) + total_vecs = max; + msix_ent =kcalloc (total_vecs,sizeof (struct msix_entry ),GFP_KERNEL );if (!msix_ent)return -ENOMEM ;
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +29 -1
@@ -116,6 +116,9 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,if (!(bp->flags &BNXT_FLAG_USING_MSIX ))return -ENODEV ; +if (edev->ulp_tbl[ulp_id].msix_requested) +return -EAGAIN ; + max_cp_rings =bnxt_get_max_func_cp_rings (bp); max_idx =min_t (int, bp->total_irqs, max_cp_rings); avail_msix = max_idx - bp->cp_nr_rings;
@@ -124,7 +127,11 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,if (avail_msix > num_msix) avail_msix = num_msix; - idx = max_idx - avail_msix; +if (bp->flags &BNXT_FLAG_NEW_RM ) + idx = bp->cp_nr_rings; +else + idx = max_idx - avail_msix; + edev->ulp_tbl[ulp_id].msix_base = idx;for (i =0 ; i < avail_msix; i++) { ent[i].vector = bp->irq_tbl[idx + i].vector; ent[i].ring_idx = idx + i;
@@ -154,6 +161,27 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)return 0 ; } +int bnxt_get_ulp_msix_num (struct bnxt *bp) +{ +if (bnxt_ulp_registered (bp->edev,BNXT_ROCE_ULP )) { +struct bnxt_en_dev *edev = bp->edev; + +return edev->ulp_tbl[BNXT_ROCE_ULP ].msix_requested; + } +return 0 ; +} + +int bnxt_get_ulp_msix_base (struct bnxt *bp) +{ +if (bnxt_ulp_registered (bp->edev,BNXT_ROCE_ULP )) { +struct bnxt_en_dev *edev = bp->edev; + +if (edev->ulp_tbl[BNXT_ROCE_ULP ].msix_requested) +return edev->ulp_tbl[BNXT_ROCE_ULP ].msix_base; + } +return 0 ; +} +void bnxt_subtract_ulp_resources (struct bnxt *bp,int ulp_id) {ASSERT_RTNL ();
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h +3 -0
@@ -49,6 +49,7 @@ struct bnxt_ulp {unsigned long *async_events_bmap;u16 max_async_event_id;u16 msix_requested; +u16 msix_base;atomic_t ref_count; };
@@ -84,6 +85,8 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)return false; } +int bnxt_get_ulp_msix_num (struct bnxt *bp); +int bnxt_get_ulp_msix_base (struct bnxt *bp);void bnxt_subtract_ulp_resources (struct bnxt *bp,int ulp_id);void bnxt_ulp_stop (struct bnxt *bp);void bnxt_ulp_start (struct bnxt *bp);
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 13/16 bnxt_en: Add IRQ remapping logic.
In reply to Michael ChanAdd remapping logic so that bnxt_en can use any arbitrary MSIX vectors. This will allow the driver to reserve one range of MSIX vectors to be used by both bnxt_en and bnxt_re. bnxt_en can now skip over the MSIX vectors used by bnxt_re.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 59 ++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 17 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +42 -17
@@ -2444,8 +2444,10 @@ static void bnxt_free_cp_rings(struct bnxt *bp)static int bnxt_alloc_cp_rings (struct bnxt *bp) { -int i, rc; +int i, rc, ulp_base_vec, ulp_msix; + ulp_msix =bnxt_get_ulp_msix_num (bp); + ulp_base_vec =bnxt_get_ulp_msix_base (bp);for (i =0 ; i < bp->cp_nr_rings; i++) {struct bnxt_napi *bnapi = bp->bnapi[i];struct bnxt_cp_ring_info *cpr;
@@ -2460,7 +2462,11 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp) rc =bnxt_alloc_ring (bp, ring);if (rc)return rc; - ring->map_idx = i; + +if (ulp_msix && i >= ulp_base_vec) + ring->map_idx = i + ulp_msix; +else + ring->map_idx = i; }return 0 ; }
@@ -3384,6 +3390,15 @@ static void bnxt_disable_int(struct bnxt *bp) } } +static int bnxt_cp_num_to_irq_num (struct bnxt *bp,int n) +{ +struct bnxt_napi *bnapi = bp->bnapi[n]; +struct bnxt_cp_ring_info *cpr; + + cpr = &bnapi->cp_ring; +return cpr->cp_ring_struct.map_idx; +} +static void bnxt_disable_int_sync (struct bnxt *bp) {int i;
@@ -3391,8 +3406,11 @@ static void bnxt_disable_int_sync(struct bnxt *bp)atomic_inc (&bp->intr_sem);bnxt_disable_int (bp); -for (i =0 ; i < bp->cp_nr_rings; i++) -synchronize_irq (bp->irq_tbl[i].vector); +for (i =0 ; i < bp->cp_nr_rings; i++) { +int map_idx =bnxt_cp_num_to_irq_num (bp, i); + +synchronize_irq (bp->irq_tbl[map_idx].vector); + } }static void bnxt_enable_int (struct bnxt *bp)
@@ -5824,6 +5842,7 @@ static void bnxt_setup_msix(struct bnxt *bp) }for (i =0 ; i < bp->cp_nr_rings; i++) { +int map_idx =bnxt_cp_num_to_irq_num (bp, i);char *attr;if (bp->flags &BNXT_FLAG_SHARED_RINGS )
@@ -5833,9 +5852,9 @@ static void bnxt_setup_msix(struct bnxt *bp)else attr ="tx" ; -snprintf (bp->irq_tbl[i].name, len,"%s-%s-%d" , dev->name, attr, - i); - bp->irq_tbl[i].handler = bnxt_msix; +snprintf (bp->irq_tbl[map_idx].name, len,"%s-%s-%d" , dev->name, + attr, i); + bp->irq_tbl[map_idx].handler = bnxt_msix; } }
@@ -6059,7 +6078,9 @@ static void bnxt_free_irq(struct bnxt *bp)return ;for (i =0 ; i < bp->cp_nr_rings; i++) { - irq = &bp->irq_tbl[i]; +int map_idx =bnxt_cp_num_to_irq_num (bp, i); + + irq = &bp->irq_tbl[map_idx];if (irq->requested) {if (irq->have_cpumask) {irq_set_affinity_hint (irq->vector,NULL );
@@ -6078,14 +6099,25 @@ static int bnxt_request_irq(struct bnxt *bp)int i, j, rc =0 ;unsigned long flags =0 ;#ifdef CONFIG_RFS_ACCEL -struct cpu_rmap *rmap = bp->dev->rx_cpu_rmap; +struct cpu_rmap *rmap;#endif + rc =bnxt_setup_int_mode (bp); +if (rc) { +netdev_err (bp->dev,"bnxt_setup_int_mode err: %x\n" , + rc); +return rc; + } +#ifdef CONFIG_RFS_ACCEL + rmap = bp->dev->rx_cpu_rmap; +#endif if (!(bp->flags &BNXT_FLAG_USING_MSIX )) flags =IRQF_SHARED ;for (i =0 , j =0 ; i < bp->cp_nr_rings; i++) { -struct bnxt_irq *irq = &bp->irq_tbl[i]; +int map_idx =bnxt_cp_num_to_irq_num (bp, i); +struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; +#ifdef CONFIG_RFS_ACCEL if (rmap && bp->bnapi[i]->rx_ring) { rc =irq_cpu_rmap_add (rmap, irq->vector);
@@ -6805,13 +6837,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) rc =bnxt_reserve_rings (bp);if (rc)return rc; - - rc =bnxt_setup_int_mode (bp); -if (rc) { -netdev_err (bp->dev,"bnxt_setup_int_mode err: %x\n" , - rc); -return rc; - } }if ((bp->flags &BNXT_FLAG_RFS ) && !(bp->flags &BNXT_FLAG_USING_MSIX )) {
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 14/16 bnxt_en: Refactor bnxt_need_reserve_rings().
In reply to Michael ChanRefactor bnxt_need_reserve_rings() slightly so that __bnxt_reserve_rings() can call it and remove some duplicated code.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 57 ++++++++++++++----------------- 1 file changed, 25 insertions(+), 32 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +25 -32
@@ -4753,6 +4753,30 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp)return cp; } +static bool bnxt_need_reserve_rings (struct bnxt *bp) +{ +struct bnxt_hw_resc *hw_resc = &bp->hw_resc; +int cp = bp->cp_nr_rings; +int rx = bp->rx_nr_rings; +int vnic =1 , grp = rx; + +if (bp->hwrm_spec_code <0x10601 ) +return false; + +if (hw_resc->resv_tx_rings != bp->tx_nr_rings) +return true; + +if (bp->flags &BNXT_FLAG_RFS ) + vnic = rx +1 ; +if (bp->flags &BNXT_FLAG_AGG_RINGS ) + rx <<=1 ; +if ((bp->flags &BNXT_FLAG_NEW_RM ) && + (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp || + hw_resc->resv_hw_ring_grps != grp || hw_resc->resv_vnics != vnic)) +return true; +return false; +} +static int bnxt_trim_rings (struct bnxt *bp,int *rx,int *tx,int max,bool shared);
@@ -4766,7 +4790,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)bool sh = false;int vnic =1 ; -if (bp->hwrm_spec_code <0x10601 ) +if (!bnxt_need_reserve_rings (bp))return 0 ;if (bp->flags &BNXT_FLAG_SHARED_RINGS )
@@ -4775,14 +4799,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp) vnic = rx +1 ;if (bp->flags &BNXT_FLAG_AGG_RINGS ) rx <<=1 ; - grp = bp->rx_nr_rings; -if (tx == hw_resc->resv_tx_rings && - (!(bp->flags &BNXT_FLAG_NEW_RM ) || - (rx == hw_resc->resv_rx_rings && - grp == hw_resc->resv_hw_ring_grps && - cp == hw_resc->resv_cp_rings && vnic == hw_resc->resv_vnics))) -return 0 ; rc =bnxt_hwrm_reserve_rings (bp, tx, rx, grp, cp, vnic);if (rc)
@@ -4826,30 +4843,6 @@ static int __bnxt_reserve_rings(struct bnxt *bp)return rc; } -static bool bnxt_need_reserve_rings (struct bnxt *bp) -{ -struct bnxt_hw_resc *hw_resc = &bp->hw_resc; -int rx = bp->rx_nr_rings; -int vnic =1 ; - -if (bp->hwrm_spec_code <0x10601 ) -return false; - -if (hw_resc->resv_tx_rings != bp->tx_nr_rings) -return true; - -if (bp->flags &BNXT_FLAG_RFS ) - vnic = rx +1 ; -if (bp->flags &BNXT_FLAG_AGG_RINGS ) - rx <<=1 ; -if ((bp->flags &BNXT_FLAG_NEW_RM ) && - (hw_resc->resv_rx_rings != rx || - hw_resc->resv_cp_rings != bp->cp_nr_rings || - hw_resc->resv_vnics != vnic)) -return true; -return false; -} -static int bnxt_hwrm_check_vf_rings (struct bnxt *bp,int tx_rings,int rx_rings,int ring_grps,int cp_rings,int vnics) {
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 15/16 bnxt_en: Reserve completion rings and MSIX for bnxt_re RDMA driver.
In reply to Michael ChanAdd additional logic to reserve completion rings for the bnxt_re driver when it requests MSIX vectors. The function bnxt_cp_rings_in_use() will return the total number of completion rings used by both drivers that need to be reserved. If the network interface in up, we will close and open the NIC to reserve the new set of completion rings and re-initialize the vectors.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 39 ++++++++++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 +++ drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 39 ++++++++++++++++++++++----- 3 files changed, 65 insertions(+), 16 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +30 -9
@@ -4756,7 +4756,7 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp)static bool bnxt_need_reserve_rings (struct bnxt *bp) {struct bnxt_hw_resc *hw_resc = &bp->hw_resc; -int cp = bp->cp_nr_rings; +int cp =bnxt_cp_rings_in_use (bp);int rx = bp->rx_nr_rings;int vnic =1 , grp = rx;
@@ -4783,9 +4783,9 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,static int __bnxt_reserve_rings (struct bnxt *bp) {struct bnxt_hw_resc *hw_resc = &bp->hw_resc; +int cp =bnxt_cp_rings_in_use (bp);int tx = bp->tx_nr_rings;int rx = bp->rx_nr_rings; -int cp = bp->cp_nr_rings;int grp, rx_rings, rc;bool sh = false;int vnic =1 ;
@@ -5908,7 +5908,7 @@ void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max) bp->hw_resc.max_cp_rings = max; } -static unsigned int bnxt_get_max_func_irqs (struct bnxt *bp) +unsigned int bnxt_get_max_func_irqs (struct bnxt *bp) {struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
@@ -5920,6 +5920,26 @@ void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs) bp->hw_resc.max_irqs = max_irqs; } +int bnxt_get_avail_msix (struct bnxt *bp,int num) +{ +int max_cp =bnxt_get_max_func_cp_rings (bp); +int max_irq =bnxt_get_max_func_irqs (bp); +int total_req = bp->cp_nr_rings + num; +int max_idx, avail_msix; + + max_idx =min_t (int, bp->total_irqs, max_cp); + avail_msix = max_idx - bp->cp_nr_rings; +if (!(bp->flags &BNXT_FLAG_NEW_RM ) || avail_msix >= num) +return avail_msix; + +if (max_irq < total_req) { + num = max_irq - bp->cp_nr_rings; +if (num <=0 ) +return 0 ; + } +return num; +} +static int bnxt_get_num_msix (struct bnxt *bp) {if (!(bp->flags &BNXT_FLAG_NEW_RM ))
@@ -5930,7 +5950,7 @@ static int bnxt_get_num_msix(struct bnxt *bp)static int bnxt_init_msix (struct bnxt *bp) { -int i, total_vecs, max, rc =0 , min =1 ; +int i, total_vecs, max, rc =0 , min =1 , ulp_msix;struct msix_entry *msix_ent; total_vecs =bnxt_get_num_msix (bp);
@@ -5951,7 +5971,8 @@ static int bnxt_init_msix(struct bnxt *bp) min =2 ; total_vecs =pci_enable_msix_range (bp->pdev, msix_ent, min, total_vecs); -if (total_vecs <0 ) { + ulp_msix =bnxt_get_ulp_msix_num (bp); +if (total_vecs <0 || total_vecs < ulp_msix) { rc = -ENODEV ; goto msix_setup_exit; }
@@ -5964,7 +5985,7 @@ static int bnxt_init_msix(struct bnxt *bp) bp->total_irqs = total_vecs;/* Trim rings based upon num of vectors allocated */ rc =bnxt_trim_rings (bp, &bp->rx_nr_rings, &bp->tx_nr_rings, - total_vecs, min ==1 ); + total_vecs - ulp_msix, min ==1 );if (rc) goto msix_setup_exit;
@@ -6028,9 +6049,8 @@ static void bnxt_clear_int_mode(struct bnxt *bp) bp->flags &= ~BNXT_FLAG_USING_MSIX ; } -static int bnxt_reserve_rings (struct bnxt *bp) +int bnxt_reserve_rings (struct bnxt *bp) { -int orig_cp = bp->hw_resc.resv_cp_rings;int tcs =netdev_get_num_tc (bp->dev);int rc;
@@ -6042,7 +6062,8 @@ static int bnxt_reserve_rings(struct bnxt *bp)netdev_err (bp->dev,"ring reservation failure rc: %d\n" , rc);return rc; } -if ((bp->flags &BNXT_FLAG_NEW_RM ) && bp->cp_nr_rings > orig_cp) { +if ((bp->flags &BNXT_FLAG_NEW_RM ) && + (bnxt_get_num_msix (bp) != bp->total_irqs)) {bnxt_clear_int_mode (bp); rc =bnxt_init_int_mode (bp);if (rc)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +3 -0
@@ -1454,7 +1454,10 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,void bnxt_set_max_func_stat_ctxs (struct bnxt *bp,unsigned int max);unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp);void bnxt_set_max_func_cp_rings (struct bnxt *bp,unsigned int max); +unsigned int bnxt_get_max_func_irqs (struct bnxt *bp);void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max); +int bnxt_get_avail_msix (struct bnxt *bp,int num); +int bnxt_reserve_rings (struct bnxt *bp);void bnxt_tx_disable (struct bnxt *bp);void bnxt_tx_enable (struct bnxt *bp);int bnxt_hwrm_set_pause (struct bnxt *);
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +32 -7
@@ -108,6 +108,7 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,struct bnxt *bp =netdev_priv (dev);int max_idx, max_cp_rings;int avail_msix, i, idx; +int rc =0 ;ASSERT_RTNL ();if (ulp_id !=BNXT_ROCE_ULP )
@@ -120,26 +121,46 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,return -EAGAIN ; max_cp_rings =bnxt_get_max_func_cp_rings (bp); - max_idx =min_t (int, bp->total_irqs, max_cp_rings); - avail_msix = max_idx - bp->cp_nr_rings; + avail_msix =bnxt_get_avail_msix (bp, num_msix);if (!avail_msix)return -ENOMEM ;if (avail_msix > num_msix) avail_msix = num_msix; -if (bp->flags &BNXT_FLAG_NEW_RM ) +if (bp->flags &BNXT_FLAG_NEW_RM ) { idx = bp->cp_nr_rings; -else + }else { + max_idx =min_t (int, bp->total_irqs, max_cp_rings); idx = max_idx - avail_msix; + } edev->ulp_tbl[ulp_id].msix_base = idx; + edev->ulp_tbl[ulp_id].msix_requested = avail_msix; +if (bp->total_irqs < (idx + avail_msix)) { +if (netif_running (dev)) { +bnxt_close_nic (bp, true, false); + rc =bnxt_open_nic (bp, true, false); + }else { + rc =bnxt_reserve_rings (bp); + } + } +if (rc) { + edev->ulp_tbl[ulp_id].msix_requested =0 ; +return -EAGAIN ; + } + +if (bp->flags &BNXT_FLAG_NEW_RM ) { +struct bnxt_hw_resc *hw_resc = &bp->hw_resc; + + avail_msix = hw_resc->resv_cp_rings - bp->cp_nr_rings; + edev->ulp_tbl[ulp_id].msix_requested = avail_msix; + }for (i =0 ; i < avail_msix; i++) { ent[i].vector = bp->irq_tbl[idx + i].vector; ent[i].ring_idx = idx + i; ent[i].db_offset = (idx + i) *0x80 ; } -bnxt_set_max_func_irqs (bp, max_idx - avail_msix); +bnxt_set_max_func_irqs (bp,bnxt_get_max_func_irqs (bp) - avail_msix);bnxt_set_max_func_cp_rings (bp, max_cp_rings - avail_msix); - edev->ulp_tbl[ulp_id].msix_requested = avail_msix;return avail_msix; }
@@ -157,7 +178,11 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id) msix_requested = edev->ulp_tbl[ulp_id].msix_requested;bnxt_set_max_func_cp_rings (bp, max_cp_rings + msix_requested); edev->ulp_tbl[ulp_id].msix_requested =0 ; -bnxt_set_max_func_irqs (bp, bp->total_irqs); +bnxt_set_max_func_irqs (bp,bnxt_get_max_func_irqs (bp) + msix_requested); +if (netif_running (dev)) { +bnxt_close_nic (bp, true, false); +bnxt_open_nic (bp, true, false); + }return 0 ; }
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 16/16 bnxt_en: Add ULP calls to stop and restart IRQs.
In reply to Michael ChanWhen the driver needs to re-initailize the IRQ vectors, we make the new ulp_irq_stop() call to tell the RDMA driver to disable and free the IRQ vectors. After IRQ vectors have been re-initailized, we make the ulp_irq_restart() call to tell the RDMA driver that IRQs can be restarted.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 81 ++++++++++++++++++++++++--- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 19 ++++--- 3 files changed, 90 insertions(+), 17 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -3
@@ -6064,8 +6064,10 @@ int bnxt_reserve_rings(struct bnxt *bp) }if ((bp->flags &BNXT_FLAG_NEW_RM ) && (bnxt_get_num_msix (bp) != bp->total_irqs)) { +bnxt_ulp_irq_stop (bp);bnxt_clear_int_mode (bp); rc =bnxt_init_int_mode (bp); +bnxt_ulp_irq_restart (bp, rc);if (rc)return rc; }
@@ -8575,16 +8577,15 @@ int bnxt_restore_pf_fw_resources(struct bnxt *bp)int rc;ASSERT_RTNL (); -if (bnxt_ulp_registered (bp->edev,BNXT_ROCE_ULP )) -return 0 ; -bnxt_hwrm_func_qcaps (bp);if (netif_running (bp->dev))__bnxt_close_nic (bp, true, false); +bnxt_ulp_irq_stop (bp);bnxt_clear_int_mode (bp); rc =bnxt_init_int_mode (bp); +bnxt_ulp_irq_restart (bp, rc);if (netif_running (bp->dev)) {if (rc)
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +74 -7
123 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h +12 -7
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2016 Broadcom Limited +* Copyright (c) 2016-2018 Broadcom Limited * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,12 @@struct hwrm_async_event_cmpl ;struct bnxt ; +struct bnxt_msix_entry { +u32 vector; +u32 ring_idx; +u32 db_offset; +}; +struct bnxt_ulp_ops {/* async_notifier() cannot sleep (in BH context) */ void (*ulp_async_notifier)(void *,struct hwrm_async_event_cmpl *);
@@ -27,12 +33,8 @@ struct bnxt_ulp_ops {void (*ulp_start)(void *);void (*ulp_sriov_config)(void *,int );void (*ulp_shutdown)(void *); -}; - -struct bnxt_msix_entry { -u32 vector; -u32 ring_idx; -u32 db_offset; +void (*ulp_irq_stop)(void *); +void (*ulp_irq_restart)(void *,struct bnxt_msix_entry *); };struct bnxt_fw_msg {
@@ -61,6 +63,7 @@ struct bnxt_en_dev {#define BNXT_EN_FLAG_ROCEV2_CAP 0x2#define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \ BNXT_EN_FLAG_ROCEV2_CAP) +#define BNXT_EN_FLAG_MSIX_REQUESTED 0x4const struct bnxt_en_ops *en_ops;struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP ]; };
@@ -92,6 +95,8 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)void bnxt_ulp_start (struct bnxt *bp);void bnxt_ulp_sriov_cfg (struct bnxt *bp,int num_vfs);void bnxt_ulp_shutdown (struct bnxt *bp); +void bnxt_ulp_irq_stop (struct bnxt *bp); +void bnxt_ulp_irq_restart (struct bnxt *bp,int err);void bnxt_ulp_async_events (struct bnxt *bp,struct hwrm_async_event_cmpl *cmpl);struct bnxt_en_dev *bnxt_ulp_probe (struct net_device *dev);
Signature · 1 line
1.8.3.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Sat, 31 Mar 2018 13:54:05 -0400
Quoted 3 lines
Misc. updates including updated firmware interface, some additional port statistics, a new IRQ assignment scheme for the RDMA driver, support for VF trust, and other changes and improvements for SRIOV.
Series applied, thank you.