bnxt_en: PTP and RSS updates
Michael Chan
maintainercover bnxt_en: PTP and RSS updates
The first 2 patches are v2 of the PTP patches posted about 3 weeks ago:
https://lore.kernel.org/netdev/[email protected]/
The devlink parameter is dropped and v2 is just to increase the timeout accuracy and to use a default timeout of 1 second.
Patches 3 to 12 implement additional RSS contexts and ntuple filters for the RSS contexts.
Michael Chan (3):
bnxt_en: Add a timeout parameter to bnxt_hwrm_port_ts_query()
bnxt_en: Simplify bnxt_rfs_capable()
bnxt_en: Refactor bnxt_set_rxfh()
Pavan Chebbi (9):
bnxt_en: Retry PTP TX timestamp from FW for 1 second
bnxt_en: Add helper function bnxt_hwrm_vnic_rss_cfg_p5()
bnxt_en: Refactor VNIC alloc and cfg functions
bnxt_en: Introduce rss ctx structure, alloc/free functions
bnxt_en: Refactor RSS indir alloc/set functions
bnxt_en: Add a new_rss_ctx parameter to bnxt_rfs_capable()
bnxt_en: Support RSS contexts in ethtool .{get|set}_rxfh()
bnxt_en: Refactor bnxt_cfg_rfs_ring_tbl_idx()
bnxt_en: Support adding ntuple rules on RSS contexts
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 348 ++++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 39 +- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 221 +++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 30 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 5 + drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 2 +- 6 files changed, 509 insertions(+), 136 deletions(-)
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 1/12 bnxt_en: Add a timeout parameter to bnxt_hwrm_port_ts_query()
The caller can pass this new timeout parameter to the function to specify the firmware timeout value when requesting the TX timestamp from the firmware. This will allow the caller to precisely control the timeout and will be used in the next patch. In this patch, the parameter is 0 which means to use the current default value.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 16 ++++++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +12 -4
@@ -109,7 +109,8 @@ static void bnxt_ptp_get_current_time(struct bnxt *bp)spin_unlock_bh (&ptp->ptp_lock); } -static int bnxt_hwrm_port_ts_query (struct bnxt *bp,u32 flags,u64 *ts) +static int bnxt_hwrm_port_ts_query (struct bnxt *bp,u32 flags,u64 *ts, +u32 txts_tmo) {struct hwrm_port_ts_query_output *resp;struct hwrm_port_ts_query_input *req;
@@ -122,10 +123,15 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) req->flags =cpu_to_le32 (flags);if ((flags &PORT_TS_QUERY_REQ_FLAGS_PATH ) ==PORT_TS_QUERY_REQ_FLAGS_PATH_TX ) { +u32 tmo_us = txts_tmo *1000 ; + req->enables =cpu_to_le16 (BNXT_PTP_QTS_TX_ENABLES ); req->ptp_seq_id =cpu_to_le32 (bp->ptp_cfg->tx_seqid); req->ptp_hdr_offset =cpu_to_le16 (bp->ptp_cfg->tx_hdr_off); - req->ts_req_timeout =cpu_to_le16 (BNXT_PTP_QTS_TIMEOUT ); +if (!tmo_us) + tmo_us =BNXT_PTP_QTS_TIMEOUT ; + tmo_us =min (tmo_us,BNXT_PTP_QTS_MAX_TMO_US ); + req->ts_req_timeout =cpu_to_le16 (txts_tmo); } resp =hwrm_req_hold (bp, req);
@@ -675,7 +681,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)u64 ts =0 , ns =0 ;int rc; - rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts); + rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts, +0 );if (!rc) {memset (×tamp,0 ,sizeof (timestamp));spin_lock_bh (&ptp->ptp_lock);
@@ -891,7 +898,8 @@ int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg)if (rc)return rc; }else { - rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME , &ns); + rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME , + &ns,0 );if (rc)return rc; }
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +1 -0
@@ -23,6 +23,7 @@#define BNXT_HI_TIMER_MASK 0xffff00000000UL#define BNXT_PTP_QTS_TIMEOUT 1000 +#define BNXT_PTP_QTS_MAX_TMO_US 65535#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \ PORT_TS_QUERY_REQ_ENABLES_PTP_HDR_OFFSET)
Signature · 1 line
2.30.1
Re: [PATCH net-next 01/12] bnxt_en: Add a timeout parameter to bnxt_hwrm_port_ts_query()
Quoted 71 lines · Michael Chan
The caller can pass this new timeout parameter to the function to specify the firmware timeout value when requesting the TX timestamp from the firmware. This will allow the caller to precisely control the timeout and will be used in the next patch. In this patch, the parameter is 0 which means to use the current default value.
Cc Vadim Fedorenko <[email protected]>Cc Richard Cochran <[email protected]>Reviewed-by Pavan Chebbi <[email protected]>Signed-off-by Michael Chan <[email protected]>--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 16 ++++++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-)drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +12
-4@@ -109,7 +109,8 @@ static void bnxt_ptp_get_current_time(struct bnxt *bp)spin_unlock_bh (&ptp->ptp_lock); } -static int bnxt_hwrm_port_ts_query (struct bnxt *bp,u32 flags,u64 *ts) +static int bnxt_hwrm_port_ts_query (struct bnxt *bp,u32 flags,u64 *ts, +u32 txts_tmo) {struct hwrm_port_ts_query_output *resp;struct hwrm_port_ts_query_input *req;@@ -122,10 +123,15 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) req->flags =cpu_to_le32 (flags);if ((flags &PORT_TS_QUERY_REQ_FLAGS_PATH ) ==PORT_TS_QUERY_REQ_FLAGS_PATH_TX ) { +u32 tmo_us = txts_tmo *1000 ; + req->enables =cpu_to_le16 (BNXT_PTP_QTS_TX_ENABLES ); req->ptp_seq_id =cpu_to_le32 (bp->ptp_cfg->tx_seqid); req->ptp_hdr_offset =cpu_to_le16 (bp->ptp_cfg->tx_hdr_off); - req->ts_req_timeout =cpu_to_le16 (BNXT_PTP_QTS_TIMEOUT ); +if (!tmo_us) + tmo_us =BNXT_PTP_QTS_TIMEOUT ; + tmo_us =min (tmo_us,BNXT_PTP_QTS_MAX_TMO_US ); + req->ts_req_timeout =cpu_to_le16 (txts_tmo); } resp =hwrm_req_hold (bp, req);@@ -675,7 +681,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)u64 ts =0 , ns =0 ;int rc; - rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts); + rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts, +0 );if (!rc) {memset (×tamp,0 ,sizeof (timestamp));spin_lock_bh (&ptp->ptp_lock);@@ -891,7 +898,8 @@ int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg)if (rc)return rc; }else { - rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME , &ns); + rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME , + &ns,0 );if (rc)return rc; }drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +0
-0
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h line 29
Quoted 7 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +1
-0@@ -23,6 +23,7 @@#define BNXT_HI_TIMER_MASK 0xffff00000000UL#define BNXT_PTP_QTS_TIMEOUT 1000 +#define BNXT_PTP_QTS_MAX_TMO_US 65535#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \ PORT_TS_QUERY_REQ_ENABLES_PTP_HDR_OFFSET)
Michael Chan
maintainerPATCH 2/12 bnxt_en: Retry PTP TX timestamp from FW for 1 second
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
Use a new default 1 second timeout value instead of the existing 1 msec value. The driver will keep track of the remaining time before timeout and will pass this value to bnxt_hwrm_port_ts_query(). The firmware supports timeout values up to 65535 usecs. If the timeout value passed to bnxt_hwrm_port_ts_query() is less than the FW max value, we will use that value to precisely control the specified timeout. If it is larger than the FW max value, we will use the FW max value and any additional retry to reach the desired timeout will be done in the context of bnxt_ptp_ts_aux_eork().
---
v2: Don't use the devlink parameter.
Pass the timeout parameter to bnxt_hwrm_port_ts_query() to precisely control the timeout.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 16 +++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +15 -1
@@ -678,11 +678,17 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) {struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;struct skb_shared_hwtstamps timestamp; +unsigned long now = jiffies;u64 ts =0 , ns =0 ; +u32 tmo =0 ;int rc; +if (!ptp->txts_pending) + ptp->abs_txts_tmo = now +msecs_to_jiffies (ptp->txts_tmo); +if (!time_after_eq (now, ptp->abs_txts_tmo)) + tmo =jiffies_to_msecs (ptp->abs_txts_tmo - now); rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts, -0 ); + tmo);if (!rc) {memset (×tamp,0 ,sizeof (timestamp));spin_lock_bh (&ptp->ptp_lock);
@@ -691,6 +697,10 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) timestamp.hwtstamp =ns_to_ktime (ns);skb_tstamp_tx (ptp->tx_skb, ×tamp); }else { +if (!time_after_eq (jiffies, ptp->abs_txts_tmo)) { + ptp->txts_pending = true; +return ; + }netdev_warn_once (bp->dev,"TS query for TX timer failed rc = %x\n" , rc); }
@@ -698,6 +708,7 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)dev_kfree_skb_any (ptp->tx_skb); ptp->tx_skb =NULL ;atomic_inc (&ptp->tx_avail); + ptp->txts_pending = false; }static long bnxt_ptp_ts_aux_work (struct ptp_clock_info *ptp_info)
@@ -721,6 +732,8 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)spin_unlock_bh (&ptp->ptp_lock); ptp->next_overflow_check = now +BNXT_PHC_OVERFLOW_PERIOD ; } +if (ptp->txts_pending) +return 0 ;return HZ ; }
@@ -973,6 +986,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)spin_unlock_bh (&ptp->ptp_lock);ptp_schedule_worker (ptp->ptp_clock,0 ); } + ptp->txts_tmo =BNXT_PTP_DFLT_TX_TMO ;return 0 ; out:
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +4 -0
@@ -22,6 +22,7 @@#define BNXT_LO_TIMER_MASK 0x0000ffffffffUL#define BNXT_HI_TIMER_MASK 0xffff00000000UL +#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */ #define BNXT_PTP_QTS_TIMEOUT 1000#define BNXT_PTP_QTS_MAX_TMO_US 65535#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \
@@ -116,11 +117,14 @@ struct bnxt_ptp_cfg { BNXT_PTP_MSG_PDELAY_REQ | \ BNXT_PTP_MSG_PDELAY_RESP) u8 tx_tstamp_en:1; + u8 txts_pending:1;int rx_filter;u32 tstamp_filters;u32 refclk_regs[2 ];u32 refclk_mapped_regs[2 ]; +u32 txts_tmo; +unsigned long abs_txts_tmo; };#if BITS_PER_LONG ==32
Signature · 1 line
2.30.1
Re: [PATCH net-next 02/12] bnxt_en: Retry PTP TX timestamp from FW for 1 second
Quoted 103 lines · Michael Chan
From: Pavan Chebbi <[email protected]>
Use a new default 1 second timeout value instead of the existing 1 msec value. The driver will keep track of the remaining time before timeout and will pass this value to
bnxt_hwrm_port_ts_query(). The firmware supports timeout values up to 65535 usecs. If the timeout value passed tobnxt_hwrm_port_ts_query()is less than the FW max value, we will use that value to precisely control the specified timeout. If it is larger than the FW max value, we will use the FW max value and any additional retry to reach the desired timeout will be done in the context ofbnxt_ptp_ts_aux_eork().Cc Vadim Fedorenko <[email protected]>Cc Richard Cochran <[email protected]>Reviewed-by Andy Gospodarek <[email protected]>Signed-off-by Pavan Chebbi <[email protected]>Signed-off-by Michael Chan <[email protected]>---
v2: Don't use the devlink parameter.
Pass the timeout parameter tobnxt_hwrm_port_ts_query()to precisely control the timeout.--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 16 +++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-)drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +15
-1@@ -678,11 +678,17 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) {struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;struct skb_shared_hwtstamps timestamp; +unsigned long now = jiffies;u64 ts =0 , ns =0 ; +u32 tmo =0 ;int rc; +if (!ptp->txts_pending) + ptp->abs_txts_tmo = now +msecs_to_jiffies (ptp->txts_tmo); +if (!time_after_eq (now, ptp->abs_txts_tmo)) + tmo =jiffies_to_msecs (ptp->abs_txts_tmo - now); rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts, -0 ); + tmo);if (!rc) {memset (×tamp,0 ,sizeof (timestamp));spin_lock_bh (&ptp->ptp_lock);@@ -691,6 +697,10 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) timestamp.hwtstamp =ns_to_ktime (ns);skb_tstamp_tx (ptp->tx_skb, ×tamp); }else { +if (!time_after_eq (jiffies, ptp->abs_txts_tmo)) { + ptp->txts_pending = true; +return ; + }netdev_warn_once (bp->dev,"TS query for TX timer failed rc = %x\n" , rc); }@@ -698,6 +708,7 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)dev_kfree_skb_any (ptp->tx_skb); ptp->tx_skb =NULL ;atomic_inc (&ptp->tx_avail); + ptp->txts_pending = false; }static long bnxt_ptp_ts_aux_work (struct ptp_clock_info *ptp_info)@@ -721,6 +732,8 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)spin_unlock_bh (&ptp->ptp_lock); ptp->next_overflow_check = now +BNXT_PHC_OVERFLOW_PERIOD ; } +if (ptp->txts_pending) +return 0 ;return HZ ; }@@ -973,6 +986,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)spin_unlock_bh (&ptp->ptp_lock);ptp_schedule_worker (ptp->ptp_clock,0 ); } + ptp->txts_tmo =BNXT_PTP_DFLT_TX_TMO ;return 0 ; out:drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +2
-0@@ -22,6 +22,7 @@#define BNXT_LO_TIMER_MASK 0x0000ffffffffUL#define BNXT_HI_TIMER_MASK 0xffff00000000UL +#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */ #define BNXT_PTP_QTS_TIMEOUT 1000#define BNXT_PTP_QTS_MAX_TMO_US 65535#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \@@ -116,11 +117,14 @@ struct bnxt_ptp_cfg { BNXT_PTP_MSG_PDELAY_REQ | \ BNXT_PTP_MSG_PDELAY_RESP) u8 tx_tstamp_en:1; + u8 txts_pending:1;
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h struct bnxt_ptp_cfg { · line 130
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +2
-0int rx_filter;u32 tstamp_filters;u32 refclk_regs[2 ];u32 refclk_mapped_regs[2 ]; +u32 txts_tmo; +unsigned long abs_txts_tmo; };#if BITS_PER_LONG ==32
Michael Chan
maintainerPATCH 3/12 bnxt_en: Add helper function bnxt_hwrm_vnic_rss_cfg_p5()
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
This is a pure refactoring patch. The new function bnxt_hwrm_vnic_set_rss_p5() will set up the P5_PLUS specific RSS ring table and then call bnxt_hwrm_vnic_cfg() to setup the vnic for proper RSS operations. This new function will be used later for additional RSS contexts.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 21 insertions(+), 11 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +20 -11
@@ -9825,6 +9825,23 @@ static int __bnxt_setup_vnic(struct bnxt *bp, u16 vnic_id)return rc; } +int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,u16 vnic_id) +{ +int rc; + + rc =bnxt_hwrm_vnic_set_rss_p5 (bp, vnic_id, true); +if (rc) { +netdev_err (bp->dev,"hwrm vnic %d set rss failure rc: %d\n" , + vnic_id, rc); +return rc; + } + rc =bnxt_hwrm_vnic_cfg (bp, vnic_id); +if (rc) +netdev_err (bp->dev,"hwrm vnic %d cfg failure rc: %x\n" , + vnic_id, rc); +return rc; +} +static int __bnxt_setup_vnic_p5 (struct bnxt *bp,u16 vnic_id) {int rc, i, nr_ctxs;
@@ -9842,18 +9859,10 @@ static int __bnxt_setup_vnic_p5(struct bnxt *bp, u16 vnic_id)if (i < nr_ctxs)return -ENOMEM ; - rc =bnxt_hwrm_vnic_set_rss_p5 (bp, vnic_id, true); -if (rc) { -netdev_err (bp->dev,"hwrm vnic %d set rss failure rc: %d\n" , - vnic_id, rc); -return rc; - } - rc =bnxt_hwrm_vnic_cfg (bp, vnic_id); -if (rc) { -netdev_err (bp->dev,"hwrm vnic %d cfg failure rc: %x\n" , - vnic_id, rc); + rc =bnxt_hwrm_vnic_rss_cfg_p5 (bp, vnic_id); +if (rc)return rc; - } +if (bp->flags &BNXT_FLAG_AGG_RINGS ) { rc =bnxt_hwrm_vnic_set_hds (bp, vnic_id);if (rc) {
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -2721,6 +2721,7 @@ int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);int bnxt_hwrm_func_resc_qcaps (struct bnxt *bp,bool all);int bnxt_hwrm_func_qcaps (struct bnxt *bp);int bnxt_hwrm_fw_set_time (struct bnxt *); +int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,u16 vnic_id);int bnxt_open_nic (struct bnxt *,bool ,bool );int bnxt_half_open_nic (struct bnxt *bp);void bnxt_half_close_nic (struct bnxt *bp);
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 4/12 bnxt_en: Refactor VNIC alloc and cfg functions
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
The current VNIC structures are stored in an array bp->vnic_info[]. The index of the array (vnic_id) is passed to all the functions that need to reference the VNIC.
This patch changes the scheme to pass the VNIC pointer instead of the vnic index. Subsequent patches will create additional VNICs that will not be stored in the bp->vnic_info[] array. Using the VNIC pointer will work for all the VNICs.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 140 +++++++++--------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 2 +- 3 files changed, 75 insertions(+), 72 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +71 -69
@@ -4241,6 +4241,7 @@ static void bnxt_init_vnics(struct bnxt *bp)int j; vnic->fw_vnic_id =INVALID_HW_RING_ID ; + vnic->vnic_id = i;for (j =0 ; j <BNXT_MAX_CTX_PER_VNIC ; j++) vnic->fw_rss_cos_lb_ctx[j] =INVALID_HW_RING_ID ;
@@ -5938,9 +5939,9 @@ static void bnxt_hwrm_vnic_update_tunl_tpa(struct bnxt *bp, req->tnl_tpa_en_bitmap =cpu_to_le32 (tunl_tpa_bmap); } -static int bnxt_hwrm_vnic_set_tpa (struct bnxt *bp,u16 vnic_id,u32 tpa_flags) +static int bnxt_hwrm_vnic_set_tpa (struct bnxt *bp,struct bnxt_vnic_info *vnic, +u32 tpa_flags) { -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];u16 max_aggs =VNIC_TPA_CFG_REQ_MAX_AGGS_MAX ;struct hwrm_vnic_tpa_cfg_input *req;int rc;
@@ -6154,9 +6155,9 @@ __bnxt_hwrm_vnic_set_rss(struct bnxt *bp, struct hwrm_vnic_rss_cfg_input *req, req->hash_key_tbl_addr =cpu_to_le64 (vnic->rss_hash_key_dma_addr); } -static int bnxt_hwrm_vnic_set_rss (struct bnxt *bp,u16 vnic_id,bool set_rss) +static int bnxt_hwrm_vnic_set_rss (struct bnxt *bp,struct bnxt_vnic_info *vnic, +bool set_rss) { -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];struct hwrm_vnic_rss_cfg_input *req;int rc;
@@ -6174,9 +6175,9 @@ static int bnxt_hwrm_vnic_set_rss(struct bnxt *bp, u16 vnic_id, bool set_rss)return hwrm_req_send (bp, req); } -static int bnxt_hwrm_vnic_set_rss_p5 (struct bnxt *bp,u16 vnic_id,bool set_rss) +static int bnxt_hwrm_vnic_set_rss_p5 (struct bnxt *bp, +struct bnxt_vnic_info *vnic,bool set_rss) { -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];struct hwrm_vnic_rss_cfg_input *req;dma_addr_t ring_tbl_map;u32 i, nr_ctxs;
@@ -6229,9 +6230,8 @@ static void bnxt_hwrm_update_rss_hash_cfg(struct bnxt *bp)hwrm_req_drop (bp, req); } -static int bnxt_hwrm_vnic_set_hds (struct bnxt *bp,u16 vnic_id) +static int bnxt_hwrm_vnic_set_hds (struct bnxt *bp,struct bnxt_vnic_info *vnic) { -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];struct hwrm_vnic_plcmodes_cfg_input *req;int rc;
@@ -6256,7 +6256,8 @@ static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, u16 vnic_id)return hwrm_req_send (bp, req); } -static void bnxt_hwrm_vnic_ctx_free_one (struct bnxt *bp,u16 vnic_id, +static void bnxt_hwrm_vnic_ctx_free_one (struct bnxt *bp, +struct bnxt_vnic_info *vnic,u16 ctx_idx) {struct hwrm_vnic_rss_cos_lb_ctx_free_input *req;
@@ -6265,10 +6266,10 @@ static void bnxt_hwrm_vnic_ctx_free_one(struct bnxt *bp, u16 vnic_id,return ; req->rss_cos_lb_ctx_id = -cpu_to_le16 (bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx]); +cpu_to_le16 (vnic->fw_rss_cos_lb_ctx[ctx_idx]);hwrm_req_send (bp, req); - bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] =INVALID_HW_RING_ID ; + vnic->fw_rss_cos_lb_ctx[ctx_idx] =INVALID_HW_RING_ID ; }static void bnxt_hwrm_vnic_ctx_free (struct bnxt *bp)
@@ -6280,13 +6281,14 @@ static void bnxt_hwrm_vnic_ctx_free(struct bnxt *bp)for (j =0 ; j <BNXT_MAX_CTX_PER_VNIC ; j++) {if (vnic->fw_rss_cos_lb_ctx[j] !=INVALID_HW_RING_ID ) -bnxt_hwrm_vnic_ctx_free_one (bp, i, j); +bnxt_hwrm_vnic_ctx_free_one (bp, vnic, j); } } bp->rsscos_nr_ctxs =0 ; } -static int bnxt_hwrm_vnic_ctx_alloc (struct bnxt *bp,u16 vnic_id,u16 ctx_idx) +static int bnxt_hwrm_vnic_ctx_alloc (struct bnxt *bp, +struct bnxt_vnic_info *vnic,u16 ctx_idx) {struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp;struct hwrm_vnic_rss_cos_lb_ctx_alloc_input *req;
@@ -6299,7 +6301,7 @@ static int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, u16 vnic_id, u16 ctx_idx) resp =hwrm_req_hold (bp, req); rc =hwrm_req_send (bp, req);if (!rc) - bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = + vnic->fw_rss_cos_lb_ctx[ctx_idx] =le16_to_cpu (resp->rss_cos_lb_ctx_id);hwrm_req_drop (bp, req);
@@ -6313,10 +6315,9 @@ static u32 bnxt_get_roce_vnic_mode(struct bnxt *bp)return VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE ; } -int bnxt_hwrm_vnic_cfg (struct bnxt *bp,u16 vnic_id) +int bnxt_hwrm_vnic_cfg (struct bnxt *bp,struct bnxt_vnic_info *vnic) {struct bnxt_vnic_info *vnic0 = &bp->vnic_info[BNXT_VNIC_DEFAULT ]; -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];struct hwrm_vnic_cfg_input *req;unsigned int ring =0 , grp_idx;u16 def_vlan =0 ;
@@ -6364,8 +6365,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)if (vnic->flags &BNXT_VNIC_RSS_FLAG ) ring =0 ;else if (vnic->flags &BNXT_VNIC_RFS_FLAG ) - ring = vnic_id -1 ; -else if ((vnic_id ==1 ) &&BNXT_CHIP_TYPE_NITRO_A0 (bp)) + ring = vnic->vnic_id -1 ; +else if ((vnic->vnic_id ==1 ) &&BNXT_CHIP_TYPE_NITRO_A0 (bp)) ring = bp->rx_nr_rings -1 ; grp_idx = bp->rx_ring[ring].bnapi->index;
@@ -6381,25 +6382,25 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)#endif 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)) +if (vnic->vnic_id ==BNXT_VNIC_DEFAULT &&bnxt_ulp_registered (bp->edev)) req->flags |=cpu_to_le32 (bnxt_get_roce_vnic_mode (bp));return hwrm_req_send (bp, req); } -static void bnxt_hwrm_vnic_free_one (struct bnxt *bp,u16 vnic_id) +static void bnxt_hwrm_vnic_free_one (struct bnxt *bp, +struct bnxt_vnic_info *vnic) { -if (bp->vnic_info[vnic_id].fw_vnic_id !=INVALID_HW_RING_ID ) { +if (vnic->fw_vnic_id !=INVALID_HW_RING_ID ) {struct hwrm_vnic_free_input *req;if (hwrm_req_init (bp, req,HWRM_VNIC_FREE ))return ; - req->vnic_id = -cpu_to_le32 (bp->vnic_info[vnic_id].fw_vnic_id); + req->vnic_id =cpu_to_le32 (vnic->fw_vnic_id);hwrm_req_send (bp, req); - bp->vnic_info[vnic_id].fw_vnic_id =INVALID_HW_RING_ID ; + vnic->fw_vnic_id =INVALID_HW_RING_ID ; } }
@@ -6408,15 +6409,14 @@ static void bnxt_hwrm_vnic_free(struct bnxt *bp)u16 i;for (i =0 ; i < bp->nr_vnics; i++) -bnxt_hwrm_vnic_free_one (bp, i); +bnxt_hwrm_vnic_free_one (bp, &bp->vnic_info[i]); } -static int bnxt_hwrm_vnic_alloc (struct bnxt *bp,u16 vnic_id, +static int bnxt_hwrm_vnic_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic,unsigned int start_rx_ring_idx,unsigned int nr_rings) {unsigned int i, j, grp_idx, end_idx = start_rx_ring_idx + nr_rings; -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];struct hwrm_vnic_alloc_output *resp;struct hwrm_vnic_alloc_input *req;int rc;
@@ -6442,7 +6442,7 @@ static int bnxt_hwrm_vnic_alloc(struct bnxt *bp, u16 vnic_id, vnic_no_ring_grps:for (i =0 ; i <BNXT_MAX_CTX_PER_VNIC ; i++) vnic->fw_rss_cos_lb_ctx[i] =INVALID_HW_RING_ID ; -if (vnic_id ==BNXT_VNIC_DEFAULT ) +if (vnic->vnic_id ==BNXT_VNIC_DEFAULT ) req->flags =cpu_to_le32 (VNIC_ALLOC_REQ_FLAGS_DEFAULT ); resp =hwrm_req_hold (bp, req);
@@ -9676,7 +9676,7 @@ static int bnxt_set_tpa(struct bnxt *bp, bool set_tpa)else if (BNXT_NO_FW_ACCESS (bp))return 0 ;for (i =0 ; i < bp->nr_vnics; i++) { - rc =bnxt_hwrm_vnic_set_tpa (bp, i, tpa_flags); + rc =bnxt_hwrm_vnic_set_tpa (bp, &bp->vnic_info[i], tpa_flags);if (rc) {netdev_err (bp->dev,"hwrm vnic set tpa failure rc for vnic %d: %x\n" , i, rc);
@@ -9691,7 +9691,7 @@ static void bnxt_hwrm_clear_vnic_rss(struct bnxt *bp)int i;for (i =0 ; i < bp->nr_vnics; i++) -bnxt_hwrm_vnic_set_rss (bp, i, false); +bnxt_hwrm_vnic_set_rss (bp, &bp->vnic_info[i], false); }static void bnxt_clear_vnic (struct bnxt *bp)
@@ -9769,28 +9769,27 @@ static int bnxt_hwrm_set_cache_line_size(struct bnxt *bp, int size)return hwrm_req_send (bp, req); } -static int __bnxt_setup_vnic (struct bnxt *bp,u16 vnic_id) +static int __bnxt_setup_vnic (struct bnxt *bp,struct bnxt_vnic_info *vnic) { -struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];int rc;if (vnic->flags &BNXT_VNIC_RFS_NEW_RSS_FLAG ) goto skip_rss_ctx;/* allocate context for vnic */ - rc =bnxt_hwrm_vnic_ctx_alloc (bp, vnic_id,0 ); + rc =bnxt_hwrm_vnic_ctx_alloc (bp, vnic,0 );if (rc) {netdev_err (bp->dev,"hwrm vnic %d alloc failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc); goto vnic_setup_err; } bp->rsscos_nr_ctxs++;if (BNXT_CHIP_TYPE_NITRO_A0 (bp)) { - rc =bnxt_hwrm_vnic_ctx_alloc (bp, vnic_id,1 ); + rc =bnxt_hwrm_vnic_ctx_alloc (bp, vnic,1 );if (rc) {netdev_err (bp->dev,"hwrm vnic %d cos ctx alloc failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc); goto vnic_setup_err; } bp->rsscos_nr_ctxs++;
@@ -9798,26 +9797,26 @@ static int __bnxt_setup_vnic(struct bnxt *bp, u16 vnic_id) skip_rss_ctx:/* configure default vnic, ring grp */ - rc =bnxt_hwrm_vnic_cfg (bp, vnic_id); + rc =bnxt_hwrm_vnic_cfg (bp, vnic);if (rc) {netdev_err (bp->dev,"hwrm vnic %d cfg failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc); goto vnic_setup_err; }/* Enable RSS hashing on vnic */ - rc =bnxt_hwrm_vnic_set_rss (bp, vnic_id, true); + rc =bnxt_hwrm_vnic_set_rss (bp, vnic, true);if (rc) {netdev_err (bp->dev,"hwrm vnic %d set rss failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc); goto vnic_setup_err; }if (bp->flags &BNXT_FLAG_AGG_RINGS ) { - rc =bnxt_hwrm_vnic_set_hds (bp, vnic_id); + rc =bnxt_hwrm_vnic_set_hds (bp, vnic);if (rc) {netdev_err (bp->dev,"hwrm vnic %d set hds failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc); } }
@@ -9825,33 +9824,33 @@ static int __bnxt_setup_vnic(struct bnxt *bp, u16 vnic_id)return rc; } -int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,u16 vnic_id) +int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic) {int rc; - rc =bnxt_hwrm_vnic_set_rss_p5 (bp, vnic_id, true); + rc =bnxt_hwrm_vnic_set_rss_p5 (bp, vnic, true);if (rc) {netdev_err (bp->dev,"hwrm vnic %d set rss failure rc: %d\n" , - vnic_id, rc); + vnic->vnic_id, rc);return rc; } - rc =bnxt_hwrm_vnic_cfg (bp, vnic_id); + rc =bnxt_hwrm_vnic_cfg (bp, vnic);if (rc)netdev_err (bp->dev,"hwrm vnic %d cfg failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc);return rc; } -static int __bnxt_setup_vnic_p5 (struct bnxt *bp,u16 vnic_id) +static int __bnxt_setup_vnic_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic) {int rc, i, nr_ctxs; nr_ctxs =bnxt_get_nr_rss_ctxs (bp, bp->rx_nr_rings);for (i =0 ; i < nr_ctxs; i++) { - rc =bnxt_hwrm_vnic_ctx_alloc (bp, vnic_id, i); + rc =bnxt_hwrm_vnic_ctx_alloc (bp, vnic, i);if (rc) {netdev_err (bp->dev,"hwrm vnic %d ctx %d alloc failure rc: %x\n" , - vnic_id, i, rc); + vnic->vnic_id, i, rc);break ; } bp->rsscos_nr_ctxs++;
@@ -9859,55 +9858,57 @@ static int __bnxt_setup_vnic_p5(struct bnxt *bp, u16 vnic_id)if (i < nr_ctxs)return -ENOMEM ; - rc =bnxt_hwrm_vnic_rss_cfg_p5 (bp, vnic_id); + rc =bnxt_hwrm_vnic_rss_cfg_p5 (bp, vnic);if (rc)return rc;if (bp->flags &BNXT_FLAG_AGG_RINGS ) { - rc =bnxt_hwrm_vnic_set_hds (bp, vnic_id); + rc =bnxt_hwrm_vnic_set_hds (bp, vnic);if (rc) {netdev_err (bp->dev,"hwrm vnic %d set hds failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc); } }return rc; } -static int bnxt_setup_vnic (struct bnxt *bp,u16 vnic_id) +static int bnxt_setup_vnic (struct bnxt *bp,struct bnxt_vnic_info *vnic) {if (bp->flags &BNXT_FLAG_CHIP_P5_PLUS ) -return __bnxt_setup_vnic_p5 (bp, vnic_id); +return __bnxt_setup_vnic_p5 (bp, vnic);else -return __bnxt_setup_vnic (bp, vnic_id); +return __bnxt_setup_vnic (bp, vnic); } -static int bnxt_alloc_and_setup_vnic (struct bnxt *bp,u16 vnic_id, +static int bnxt_alloc_and_setup_vnic (struct bnxt *bp, +struct bnxt_vnic_info *vnic,u16 start_rx_ring_idx,int rx_rings) {int rc; - rc =bnxt_hwrm_vnic_alloc (bp, vnic_id, start_rx_ring_idx, rx_rings); + rc =bnxt_hwrm_vnic_alloc (bp, vnic, start_rx_ring_idx, rx_rings);if (rc) {netdev_err (bp->dev,"hwrm vnic %d alloc failure rc: %x\n" , - vnic_id, rc); + vnic->vnic_id, rc);return rc; } -return bnxt_setup_vnic (bp, vnic_id); +return bnxt_setup_vnic (bp, vnic); }static int bnxt_alloc_rfs_vnics (struct bnxt *bp) { +struct bnxt_vnic_info *vnic;int i, rc =0 ; -if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) -return bnxt_alloc_and_setup_vnic (bp,BNXT_VNIC_NTUPLE ,0 , - bp->rx_nr_rings); +if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) { + vnic = &bp->vnic_info[BNXT_VNIC_NTUPLE ]; +return bnxt_alloc_and_setup_vnic (bp, vnic,0 , bp->rx_nr_rings); + }if (bp->flags &BNXT_FLAG_CHIP_P5_PLUS )return 0 ;for (i =0 ; i < bp->rx_nr_rings; i++) { -struct bnxt_vnic_info *vnic;u16 vnic_id = i +1 ;u16 ring_id = i;
@@ -9918,7 +9919,7 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp) vnic->flags |=BNXT_VNIC_RFS_FLAG ;if (bp->rss_cap &BNXT_RSS_CAP_NEW_RSS_CAP ) vnic->flags |=BNXT_VNIC_RFS_NEW_RSS_FLAG ; -if (bnxt_alloc_and_setup_vnic (bp, vnic_id, ring_id,1 )) +if (bnxt_alloc_and_setup_vnic (bp, &bp->vnic_info[vnic_id], ring_id,1 ))break ; }return rc;
@@ -9936,16 +9937,17 @@ static bool bnxt_promisc_ok(struct bnxt *bp)static int bnxt_setup_nitroa0_vnic (struct bnxt *bp) { +struct bnxt_vnic_info *vnic = &bp->vnic_info[1 ];unsigned int rc =0 ; - rc =bnxt_hwrm_vnic_alloc (bp,1 , bp->rx_nr_rings -1 ,1 ); + rc =bnxt_hwrm_vnic_alloc (bp, vnic, bp->rx_nr_rings -1 ,1 );if (rc) {netdev_err (bp->dev,"Cannot allocate special vnic for NS2 A0: %x\n" , rc);return rc; } - rc =bnxt_hwrm_vnic_cfg (bp,1 ); + rc =bnxt_hwrm_vnic_cfg (bp, vnic);if (rc) {netdev_err (bp->dev,"Cannot allocate special vnic for NS2 A0: %x\n" , rc);
@@ -9988,7 +9990,7 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) rx_nr_rings--;/* default vnic 0 */ - rc =bnxt_hwrm_vnic_alloc (bp,BNXT_VNIC_DEFAULT ,0 , rx_nr_rings); + rc =bnxt_hwrm_vnic_alloc (bp, vnic,0 , rx_nr_rings);if (rc) {netdev_err (bp->dev,"hwrm vnic alloc failure rc: %x\n" , rc); goto err_out;
@@ -9997,7 +9999,7 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)if (BNXT_VF (bp))bnxt_hwrm_func_qcfg (bp); - rc =bnxt_setup_vnic (bp,BNXT_VNIC_DEFAULT ); + rc =bnxt_setup_vnic (bp, vnic);if (rc) goto err_out;if (bp->rss_cap &BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA )
drivers/net/ethernet/broadcom/bnxt/bnxt.h +3 -2
@@ -1256,6 +1256,7 @@ struct bnxt_vnic_info {#define BNXT_VNIC_UCAST_FLAG 8#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10#define BNXT_VNIC_NTUPLE_FLAG 0x20 +u32 vnic_id; };struct bnxt_hw_rings {
@@ -2695,7 +2696,7 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, struct bnxt_ntuple_filter *fltr);void bnxt_fill_ipv6_mask (__be32 mask[4 ]);int bnxt_get_nr_rss_ctxs (struct bnxt *bp,int rx_rings); -int bnxt_hwrm_vnic_cfg (struct bnxt *bp,u16 vnic_id); +int bnxt_hwrm_vnic_cfg (struct bnxt *bp,struct bnxt_vnic_info *vnic);int __bnxt_hwrm_get_tx_rings (struct bnxt *bp,u16 fid,int *tx_rings);int bnxt_nq_rings_in_use (struct bnxt *bp);int bnxt_hwrm_set_coal (struct bnxt *);
@@ -2721,7 +2722,7 @@ int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);int bnxt_hwrm_func_resc_qcaps (struct bnxt *bp,bool all);int bnxt_hwrm_func_qcaps (struct bnxt *bp);int bnxt_hwrm_fw_set_time (struct bnxt *); -int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,u16 vnic_id); +int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic);int bnxt_open_nic (struct bnxt *,bool ,bool );int bnxt_half_open_nic (struct bnxt *bp);void bnxt_half_close_nic (struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +1 -1
@@ -71,7 +71,7 @@ int bnxt_register_dev(struct bnxt_en_dev *edev,rcu_assign_pointer (ulp->ulp_ops, ulp_ops);if (test_bit (BNXT_STATE_OPEN , &bp->state)) -bnxt_hwrm_vnic_cfg (bp,0 ); +bnxt_hwrm_vnic_cfg (bp, &bp->vnic_info[BNXT_VNIC_DEFAULT ]);bnxt_fill_msix_vecs (bp, bp->edev->msix_entries); edev->flags |=BNXT_EN_FLAG_MSIX_REQUESTED ;
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 5/12 bnxt_en: Introduce rss ctx structure, alloc/free functions
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
Add struct bnxt_rss_ctx, related storage lists, required defines, and its alloc/free functions.
Later patches will use them in order to support multiple RSS contexts.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 54 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 24 +++++++++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 + 3 files changed, 80 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +54 -0
@@ -9925,6 +9925,53 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp)return rc; } +void bnxt_del_one_rss_ctx (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx, +bool all) +{ +if (!all) +return ; + +list_del (&rss_ctx->list); + bp->num_rss_ctx--; +clear_bit (rss_ctx->index, bp->rss_ctx_bmap); +kfree (rss_ctx); +} + +struct bnxt_rss_ctx *bnxt_alloc_rss_ctx (struct bnxt *bp) +{ +struct bnxt_rss_ctx *rss_ctx =NULL ; + + rss_ctx =kzalloc (sizeof (*rss_ctx),GFP_KERNEL ); +if (rss_ctx) { + rss_ctx->vnic.rss_ctx = rss_ctx; +list_add_tail (&rss_ctx->list, &bp->rss_ctx_list); + bp->num_rss_ctx++; + } +return rss_ctx; +} + +void bnxt_clear_rss_ctxs (struct bnxt *bp,bool all) +{ +struct bnxt_rss_ctx *rss_ctx, *tmp; + +list_for_each_entry_safe (rss_ctx, tmp, &bp->rss_ctx_list, list) +bnxt_del_one_rss_ctx (bp, rss_ctx, all); + +if (all) +bitmap_free (bp->rss_ctx_bmap); +} + +static void bnxt_init_multi_rss_ctx (struct bnxt *bp) +{ + bp->rss_ctx_bmap =bitmap_zalloc (BNXT_RSS_CTX_BMAP_LEN ,GFP_KERNEL ); +if (bp->rss_ctx_bmap) { +/* burn index 0 since we cannot have context 0 */ +__set_bit (0 , bp->rss_ctx_bmap); +INIT_LIST_HEAD (&bp->rss_ctx_list); + bp->rss_cap |=BNXT_RSS_CAP_MULTI_RSS_CTX ; + } +} +/* Allow PF, trusted VFs and VFs with default VLAN to be in promiscuous mode */ static bool bnxt_promisc_ok (struct bnxt *bp) {
@@ -14612,6 +14659,8 @@ static void bnxt_remove_one(struct pci_dev *pdev)unregister_netdev (dev);bnxt_free_l2_filters (bp, true);bnxt_free_ntp_fltrs (bp, true); +if (BNXT_SUPPORTS_MULTI_RSS_CTX (bp)) +bnxt_clear_rss_ctxs (bp, true);clear_bit (BNXT_STATE_IN_FW_RESET , &bp->state);/* Flush any pending tasks */ cancel_work_sync (&bp->sp_task);
@@ -15223,6 +15272,9 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)INIT_LIST_HEAD (&bp->usr_fltr_list); +if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) +bnxt_init_multi_rss_ctx (bp); + rc =register_netdev (dev);if (rc) goto init_err_cleanup;
@@ -15243,6 +15295,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)bnxt_clear_int_mode (bp); init_err_pci_clean: +if (BNXT_SUPPORTS_MULTI_RSS_CTX (bp)) +bnxt_clear_rss_ctxs (bp, true);bnxt_hwrm_func_drv_unrgtr (bp);bnxt_free_hwrm_resources (bp);bnxt_hwmon_uninit (bp);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +24 -0
@@ -1256,9 +1256,21 @@ struct bnxt_vnic_info {#define BNXT_VNIC_UCAST_FLAG 8#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10#define BNXT_VNIC_NTUPLE_FLAG 0x20 +#define BNXT_VNIC_RSSCTX_FLAG 0x40 +struct bnxt_rss_ctx *rss_ctx;u32 vnic_id; }; +struct bnxt_rss_ctx { +struct list_head list; +struct bnxt_vnic_info vnic; +u16 *rss_indir_tbl; +u8 index; +}; + +#define BNXT_MAX_ETH_RSS_CTX 32 +#define BNXT_RSS_CTX_BMAP_LEN (BNXT_MAX_ETH_RSS_CTX + 1) +struct bnxt_hw_rings {int tx;int rx;
@@ -2228,6 +2240,9 @@ struct bnxt {/* grp_info indexed by completion ring index */ struct bnxt_ring_grp_info *grp_info;struct bnxt_vnic_info *vnic_info; +struct list_head rss_ctx_list; +unsigned long *rss_ctx_bmap; +u32 num_rss_ctx;int nr_vnics;u16 *rss_indir_tbl;u16 rss_indir_tbl_entries;
@@ -2242,6 +2257,7 @@ struct bnxt {#define BNXT_RSS_CAP_AH_V6_RSS_CAP BIT(5)#define BNXT_RSS_CAP_ESP_V4_RSS_CAP BIT(6)#define BNXT_RSS_CAP_ESP_V6_RSS_CAP BIT(7) +#define BNXT_RSS_CAP_MULTI_RSS_CTX BIT(8)u8 rss_hash_key[HW_HASH_KEY_SIZE ]; u8 rss_hash_key_valid:1;
@@ -2341,6 +2357,10 @@ struct bnxt {#define BNXT_SUPPORTS_NTUPLE_VNIC (bp) \ (BNXT_PF(bp) && ((bp)->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3)) +#define BNXT_SUPPORTS_MULTI_RSS_CTX (bp) \ + (BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) && \ + ((bp)->rss_cap & BNXT_RSS_CAP_MULTI_RSS_CTX)) +u32 hwrm_spec_code;u16 hwrm_cmd_seq;u16 hwrm_cmd_kong_seq;
@@ -2723,6 +2743,10 @@ int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all);int bnxt_hwrm_func_qcaps (struct bnxt *bp);int bnxt_hwrm_fw_set_time (struct bnxt *);int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic); +void bnxt_del_one_rss_ctx (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx, +bool all); +struct bnxt_rss_ctx *bnxt_alloc_rss_ctx (struct bnxt *bp); +void bnxt_clear_rss_ctxs (struct bnxt *bp,bool all);int bnxt_open_nic (struct bnxt *,bool ,bool );int bnxt_half_open_nic (struct bnxt *bp);void bnxt_half_close_nic (struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +2 -0
@@ -969,6 +969,8 @@ static int bnxt_set_channels(struct net_device *dev, }bnxt_clear_usr_fltrs (bp, true); +if (BNXT_SUPPORTS_MULTI_RSS_CTX (bp)) +bnxt_clear_rss_ctxs (bp, false);if (netif_running (dev)) {if (BNXT_PF (bp)) {/* TODO CHIMP_FW: Send message to all VF's
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 6/12 bnxt_en: Refactor RSS indir alloc/set functions
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
We will need to dynamically allocate and change indirection tables for additional RSS contexts. Add the rss_ctx pointer parameter to bnxt_alloc_rss_indir_tbl() and bnxt_set_dflt_rss_indir_tbl(). Existing usage will always pass rss_ctx as NULL which means the default RSS context.
When supporting additional RSS contexts in subsequent patches, we'll pass the valid rss_ctx to these 2 functions.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ 2 files changed, 23 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +21 -10
@@ -6026,9 +6026,10 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr)return bnxt_cp_ring_from_grp (bp, &txr->tx_ring_struct); } -static int bnxt_alloc_rss_indir_tbl (struct bnxt *bp) +int bnxt_alloc_rss_indir_tbl (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx) {int entries; +u16 *tbl;if (bp->flags &BNXT_FLAG_CHIP_P5_PLUS ) entries =BNXT_MAX_RSS_TABLE_ENTRIES_P5 ;
@@ -6036,16 +6037,22 @@ static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp) entries =HW_HASH_INDEX_SIZE ; bp->rss_indir_tbl_entries = entries; - bp->rss_indir_tbl =kmalloc_array (entries,sizeof (*bp->rss_indir_tbl), -GFP_KERNEL ); -if (!bp->rss_indir_tbl) + tbl =kmalloc_array (entries,sizeof (*bp->rss_indir_tbl),GFP_KERNEL ); +if (!tbl)return -ENOMEM ; + +if (rss_ctx) + rss_ctx->rss_indir_tbl = tbl; +else + bp->rss_indir_tbl = tbl; +return 0 ; } -static void bnxt_set_dflt_rss_indir_tbl (struct bnxt *bp) +void bnxt_set_dflt_rss_indir_tbl (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx) {u16 max_rings, max_entries, pad, i; +u16 *rss_indir_tbl;if (!bp->rx_nr_rings)return ;
@@ -6056,13 +6063,17 @@ static void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp) max_rings = bp->rx_nr_rings; max_entries =bnxt_get_rxfh_indir_size (bp->dev); +if (rss_ctx) + rss_indir_tbl = &rss_ctx->rss_indir_tbl[0 ]; +else + rss_indir_tbl = &bp->rss_indir_tbl[0 ];for (i =0 ; i < max_entries; i++) - bp->rss_indir_tbl[i] =ethtool_rxfh_indir_default (i, max_rings); + rss_indir_tbl[i] =ethtool_rxfh_indir_default (i, max_rings); pad = bp->rss_indir_tbl_entries - max_entries;if (pad) -memset (&bp->rss_indir_tbl[i],0 , pad *sizeof (u16)); +memset (&rss_indir_tbl[i],0 , pad *sizeof (u16)); }static u16 bnxt_get_max_rss_ring (struct bnxt *bp)
@@ -7341,7 +7352,7 @@ static void bnxt_check_rss_tbl_no_rmgr(struct bnxt *bp)if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { hw_resc->resv_rx_rings = bp->rx_nr_rings;if (!netif_is_rxfh_configured (bp->dev)) -bnxt_set_dflt_rss_indir_tbl (bp); +bnxt_set_dflt_rss_indir_tbl (bp,NULL ); } }
@@ -7497,7 +7508,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)return -ENOMEM ;if (!netif_is_rxfh_configured (bp->dev)) -bnxt_set_dflt_rss_indir_tbl (bp); +bnxt_set_dflt_rss_indir_tbl (bp,NULL );return rc; }
@@ -15119,7 +15130,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bp->flags |=BNXT_FLAG_CHIP_P7 ; } - rc =bnxt_alloc_rss_indir_tbl (bp); + rc =bnxt_alloc_rss_indir_tbl (bp,NULL );if (rc) goto init_err_pci_clean;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -2715,6 +2715,8 @@ int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,int bnxt_hwrm_cfa_ntuple_filter_alloc (struct bnxt *bp,struct bnxt_ntuple_filter *fltr);void bnxt_fill_ipv6_mask (__be32 mask[4 ]); +int bnxt_alloc_rss_indir_tbl (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx); +void bnxt_set_dflt_rss_indir_tbl (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx);int bnxt_get_nr_rss_ctxs (struct bnxt *bp,int rx_rings);int bnxt_hwrm_vnic_cfg (struct bnxt *bp,struct bnxt_vnic_info *vnic);int __bnxt_hwrm_get_tx_rings (struct bnxt *bp,u16 fid,int *tx_rings);
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 7/12 bnxt_en: Simplify bnxt_rfs_capable()
In reply to Michael Chanbnxt_rfs_capable() determines the number of VNICs and RSS_CTXs required to support aRFS and then reserves the resources. We already have functions bnxt_get_total_vnics() and bnxt_get_total_rss_ctxs() to do that. Simplify the code by calling these functions. It is also more correct to do the resource reservation after bnxt_can_reserve_rings() returns true.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -15
@@ -12479,28 +12479,19 @@ static bool bnxt_rfs_capable(struct bnxt *bp)struct bnxt_hw_rings hwr = {0 };int max_vnics, max_rss_ctxs; - hwr.rss_ctx =1 ; -if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) { -/* 2 VNICS: default + Ntuple */ - hwr.vnic =2 ; - hwr.rss_ctx =bnxt_get_nr_rss_ctxs (bp, bp->rx_nr_rings) * - hwr.vnic; - goto check_reserve_vnic; - } -if (bp->flags &BNXT_FLAG_CHIP_P5_PLUS ) +if ((bp->flags &BNXT_FLAG_CHIP_P5_PLUS ) && + !BNXT_SUPPORTS_NTUPLE_VNIC (bp))return bnxt_rfs_supported (bp); +if (!(bp->flags &BNXT_FLAG_MSIX_CAP ) || !bnxt_can_reserve_rings (bp) || !bp->rx_nr_rings)return false; - hwr.vnic =1 + bp->rx_nr_rings; -check_reserve_vnic: + hwr.grp = bp->rx_nr_rings; + hwr.vnic =bnxt_get_total_vnics (bp, bp->rx_nr_rings); + hwr.rss_ctx =bnxt_get_total_rss_ctxs (bp, &hwr); max_vnics =bnxt_get_max_func_vnics (bp); max_rss_ctxs =bnxt_get_max_func_rss_ctxs (bp); -if (!(bp->flags &BNXT_FLAG_CHIP_P5_PLUS ) && - !(bp->rss_cap &BNXT_RSS_CAP_NEW_RSS_CAP )) - hwr.rss_ctx = hwr.vnic; -if (hwr.vnic > max_vnics || hwr.rss_ctx > max_rss_ctxs) {if (bp->rx_nr_rings >1 ) netdev_warn(bp->dev,
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 8/12 bnxt_en: Add a new_rss_ctx parameter to bnxt_rfs_capable()
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
Modify bnxt_rfs_capable() to check that there are enough resources to support aRFS/ntuple filters for a new RSS context requested by the user. Existing use cases in the driver will always set the new parameter to false.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -4
@@ -7360,7 +7360,7 @@ static int bnxt_get_total_vnics(struct bnxt *bp, int rx_rings) {if (bp->flags &BNXT_FLAG_RFS ) {if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) -return 2 ; +return 2 + bp->num_rss_ctx;if (!(bp->flags &BNXT_FLAG_CHIP_P5_PLUS ))return rx_rings +1 ; }
@@ -12474,7 +12474,7 @@ static bool bnxt_rfs_supported(struct bnxt *bp) }/* If runtime conditions support RFS */ -static bool bnxt_rfs_capable (struct bnxt *bp) +bool bnxt_rfs_capable (struct bnxt *bp,bool new_rss_ctx) {struct bnxt_hw_rings hwr = {0 };int max_vnics, max_rss_ctxs;
@@ -12488,6 +12488,8 @@ static bool bnxt_rfs_capable(struct bnxt *bp) hwr.grp = bp->rx_nr_rings; hwr.vnic =bnxt_get_total_vnics (bp, bp->rx_nr_rings); +if (new_rss_ctx) + hwr.vnic++; hwr.rss_ctx =bnxt_get_total_rss_ctxs (bp, &hwr); max_vnics =bnxt_get_max_func_vnics (bp); max_rss_ctxs =bnxt_get_max_func_rss_ctxs (bp);
@@ -12525,7 +12527,7 @@ static netdev_features_t bnxt_fix_features(struct net_device *dev,struct bnxt *bp =netdev_priv (dev);netdev_features_t vlan_features; -if ((features &NETIF_F_NTUPLE ) && !bnxt_rfs_capable (bp)) +if ((features &NETIF_F_NTUPLE ) && !bnxt_rfs_capable (bp, false)) features &= ~NETIF_F_NTUPLE ;if ((bp->flags &BNXT_FLAG_NO_AGG_RINGS ) || bp->xdp_prog)
@@ -13661,7 +13663,7 @@ static void bnxt_set_dflt_rfs(struct bnxt *bp) bp->flags &= ~BNXT_FLAG_RFS ;if (bnxt_rfs_supported (bp)) { dev->hw_features |=NETIF_F_NTUPLE ; -if (bnxt_rfs_capable (bp)) { +if (bnxt_rfs_capable (bp, false)) { bp->flags |=BNXT_FLAG_RFS ; dev->features |=NETIF_F_NTUPLE ; }
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -2756,6 +2756,7 @@ void bnxt_reenable_sriov(struct bnxt *bp);void bnxt_close_nic (struct bnxt *,bool ,bool );void bnxt_get_ring_err_stats (struct bnxt *bp,struct bnxt_total_ring_err_stats *stats); +bool bnxt_rfs_capable (struct bnxt *bp,bool new_rss_ctx);int bnxt_dbg_hwrm_rd_reg (struct bnxt *bp,u32 reg_off,u16 num_words,u32 *reg_buf);void bnxt_fw_exception (struct bnxt *bp);
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 9/12 bnxt_en: Refactor bnxt_set_rxfh()
In reply to Michael ChanAdd a new bnxt_modify_rss() function to modify the RSS key and RSS indirection table. The new function can modify the parameters for the default context or additional contexts.
--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +27 -13
@@ -1778,6 +1778,32 @@ static int bnxt_get_rxfh(struct net_device *dev,return 0 ; } +static void bnxt_modify_rss (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx, +struct ethtool_rxfh_param *rxfh) +{ +if (rxfh->key) { +if (rss_ctx) { +memcpy (rss_ctx->vnic.rss_hash_key, rxfh->key, +HW_HASH_KEY_SIZE ); + }else { +memcpy (bp->rss_hash_key, rxfh->key,HW_HASH_KEY_SIZE ); + bp->rss_hash_key_updated = true; + } + } +if (rxfh->indir) { +u32 i, pad, tbl_size =bnxt_get_rxfh_indir_size (bp->dev); +u16 *indir_tbl = bp->rss_indir_tbl; + +if (rss_ctx) + indir_tbl = rss_ctx->rss_indir_tbl; +for (i =0 ; i < tbl_size; i++) + indir_tbl[i] = rxfh->indir[i]; + pad = bp->rss_indir_tbl_entries - tbl_size; +if (pad) +memset (&bp->rss_indir_tbl[i],0 , pad *sizeof (u16)); + } +} +static int bnxt_set_rxfh (struct net_device *dev,struct ethtool_rxfh_param *rxfh,struct netlink_ext_ack *extack)
@@ -1788,20 +1814,8 @@ static int bnxt_set_rxfh(struct net_device *dev,if (rxfh->hfunc && rxfh->hfunc !=ETH_RSS_HASH_TOP )return -EOPNOTSUPP ; -if (rxfh->key) { -memcpy (bp->rss_hash_key, rxfh->key,HW_HASH_KEY_SIZE ); - bp->rss_hash_key_updated = true; - } - -if (rxfh->indir) { -u32 i, pad, tbl_size =bnxt_get_rxfh_indir_size (dev); +bnxt_modify_rss (bp,NULL , rxfh); -for (i =0 ; i < tbl_size; i++) - bp->rss_indir_tbl[i] = rxfh->indir[i]; - pad = bp->rss_indir_tbl_entries - tbl_size; -if (pad) -memset (&bp->rss_indir_tbl[i],0 , pad *sizeof (u16)); - }bnxt_clear_usr_fltrs (bp, false);if (netif_running (bp->dev)) {bnxt_close_nic (bp, false, false);
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 10/12 bnxt_en: Support RSS contexts in ethtool .{get|set}_rxfh()
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
Support up to 32 RSS contexts per device if supported by the device.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 49 +++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 7 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 148 +++++++++++++++++- 3 files changed, 196 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +43 -6
@@ -5939,8 +5939,8 @@ static void bnxt_hwrm_vnic_update_tunl_tpa(struct bnxt *bp, req->tnl_tpa_en_bitmap =cpu_to_le32 (tunl_tpa_bmap); } -static int bnxt_hwrm_vnic_set_tpa (struct bnxt *bp,struct bnxt_vnic_info *vnic, -u32 tpa_flags) +int bnxt_hwrm_vnic_set_tpa (struct bnxt *bp,struct bnxt_vnic_info *vnic, +u32 tpa_flags) {u16 max_aggs =VNIC_TPA_CFG_REQ_MAX_AGGS_MAX ;struct hwrm_vnic_tpa_cfg_input *req;
@@ -6129,6 +6129,8 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp,if (vnic->flags &BNXT_VNIC_NTUPLE_FLAG ) j =ethtool_rxfh_indir_default (i, bp->rx_nr_rings); +else if (vnic->flags &BNXT_VNIC_RSSCTX_FLAG ) + j = vnic->rss_ctx->rss_indir_tbl[i];else j = bp->rss_indir_tbl[i]; rxr = &bp->rx_ring[j];
@@ -6423,9 +6425,9 @@ static void bnxt_hwrm_vnic_free(struct bnxt *bp)bnxt_hwrm_vnic_free_one (bp, &bp->vnic_info[i]); } -static int bnxt_hwrm_vnic_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic, -unsigned int start_rx_ring_idx, -unsigned int nr_rings) +int bnxt_hwrm_vnic_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic, +unsigned int start_rx_ring_idx, +unsigned int nr_rings) {unsigned int i, j, grp_idx, end_idx = start_rx_ring_idx + nr_rings;struct hwrm_vnic_alloc_output *resp;
@@ -9852,7 +9854,7 @@ int bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)return rc; } -static int __bnxt_setup_vnic_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic) +int __bnxt_setup_vnic_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic) {int rc, i, nr_ctxs;
@@ -9939,15 +9941,46 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp)void bnxt_del_one_rss_ctx (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx,bool all) { +struct bnxt_vnic_info *vnic = &rss_ctx->vnic; +int i; + +bnxt_hwrm_vnic_free_one (bp, &rss_ctx->vnic); +for (i =0 ; i <BNXT_MAX_CTX_PER_VNIC ; i++) { +if (vnic->fw_rss_cos_lb_ctx[i] !=INVALID_HW_RING_ID ) +bnxt_hwrm_vnic_ctx_free_one (bp, vnic, i); + }if (!all)return ; +if (vnic->rss_table) +dma_free_coherent (&bp->pdev->dev, vnic->rss_table_size, + vnic->rss_table, + vnic->rss_table_dma_addr); +kfree (rss_ctx->rss_indir_tbl);list_del (&rss_ctx->list); bp->num_rss_ctx--;clear_bit (rss_ctx->index, bp->rss_ctx_bmap);kfree (rss_ctx); } +static void bnxt_hwrm_realloc_rss_ctx_vnic (struct bnxt *bp) +{ +bool set_tpa = !!(bp->flags &BNXT_FLAG_TPA ); +struct bnxt_rss_ctx *rss_ctx, *tmp; + +list_for_each_entry_safe (rss_ctx, tmp, &bp->rss_ctx_list, list) { +struct bnxt_vnic_info *vnic = &rss_ctx->vnic; + +if (bnxt_hwrm_vnic_alloc (bp, vnic,0 , bp->rx_nr_rings) || +bnxt_hwrm_vnic_set_tpa (bp, vnic, set_tpa) || +__bnxt_setup_vnic_p5 (bp, vnic)) { +netdev_err (bp->dev,"Failed to restore RSS ctx %d\n" , + rss_ctx->index); +bnxt_del_one_rss_ctx (bp, rss_ctx, true); + } + } +} +struct bnxt_rss_ctx *bnxt_alloc_rss_ctx (struct bnxt *bp) {struct bnxt_rss_ctx *rss_ctx =NULL ;
@@ -11829,6 +11862,8 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)bnxt_vf_reps_open (bp);bnxt_ptp_init_rtc (bp, true);bnxt_ptp_cfg_tstamp_filters (bp); +if (BNXT_SUPPORTS_MULTI_RSS_CTX (bp)) +bnxt_hwrm_realloc_rss_ctx_vnic (bp);bnxt_cfg_usr_fltrs (bp);return 0 ;
@@ -11977,6 +12012,8 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,while (bnxt_drv_busy (bp))msleep (20 ); +if (BNXT_SUPPORTS_MULTI_RSS_CTX (bp)) +bnxt_clear_rss_ctxs (bp, false);/* Flush rings and disable interrupts */ bnxt_shutdown_nic (bp, irq_re_init);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +7 -0
@@ -1270,6 +1270,7 @@ struct bnxt_rss_ctx {#define BNXT_MAX_ETH_RSS_CTX 32#define BNXT_RSS_CTX_BMAP_LEN (BNXT_MAX_ETH_RSS_CTX + 1) +#define BNXT_VNIC_ID_INVALID 0xffffffffstruct bnxt_hw_rings {int tx;
@@ -2714,11 +2715,16 @@ int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, struct bnxt_ntuple_filter *fltr);int bnxt_hwrm_cfa_ntuple_filter_alloc (struct bnxt *bp,struct bnxt_ntuple_filter *fltr); +int bnxt_hwrm_vnic_set_tpa (struct bnxt *bp,struct bnxt_vnic_info *vnic, +u32 tpa_flags);void bnxt_fill_ipv6_mask (__be32 mask[4 ]);int bnxt_alloc_rss_indir_tbl (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx);void bnxt_set_dflt_rss_indir_tbl (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx);int bnxt_get_nr_rss_ctxs (struct bnxt *bp,int rx_rings);int bnxt_hwrm_vnic_cfg (struct bnxt *bp,struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic, +unsigned int start_rx_ring_idx, +unsigned int nr_rings);int __bnxt_hwrm_get_tx_rings (struct bnxt *bp,u16 fid,int *tx_rings);int bnxt_nq_rings_in_use (struct bnxt *bp);int bnxt_hwrm_set_coal (struct bnxt *);
@@ -2745,6 +2751,7 @@ int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all);int bnxt_hwrm_func_qcaps (struct bnxt *bp);int bnxt_hwrm_fw_set_time (struct bnxt *);int bnxt_hwrm_vnic_rss_cfg_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic); +int __bnxt_setup_vnic_p5 (struct bnxt *bp,struct bnxt_vnic_info *vnic);void bnxt_del_one_rss_ctx (struct bnxt *bp,struct bnxt_rss_ctx *rss_ctx,bool all);struct bnxt_rss_ctx *bnxt_alloc_rss_ctx (struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +146 -2
187 lines not on this page · raw message
Signature · 1 line
2.30.1
Re: [PATCH net-next 10/12] bnxt_en: Support RSS contexts in ethtool .{get|set}_rxfh()
Quoted 3 lines · Michael Chan
From: Pavan Chebbi <[email protected]>
Support up to 32 RSS contexts per device if supported by the device.
Is this maximum of 32 driven by hardware limitations, or was a fixed
limit chosen to simplify state management on the driver side?
I ask because at some point in the future I hope to get back to my
rewrite of the kernel API (see [1]) and this info may help me to port your driver correctly.
-ed
Pavan Chebbi
maintainerRe: [PATCH net-next 10/12] bnxt_en: Support RSS contexts in ethtool .{get|set}_rxfh()
Quoted 8 lines · Edward Cree
Quoted 3 lines · Michael Chan
From: Pavan Chebbi <[email protected]>
Support up to 32 RSS contexts per device if supported by the device.
Is this maximum of 32 driven by hardware limitations, or was a fixed
limit chosen to simplify state management on the driver side?
It's the latter for now. However, though much higher, the hardware does have a limit. (different on every generation of the chip) So I guess we need the limit identifier in your work. Thanks for reviewing.
Quoted 7 lines
I ask because at some point in the future I hope to get back to my
rewrite of the kernel API (see [1]) and this info may help me to port your driver correctly.-ed
Michael Chan
maintainerPATCH 11/12 bnxt_en: Refactor bnxt_cfg_rfs_ring_tbl_idx()
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
Refactor bnxt_cfg_rfs_ring_tbl_idx() to pass in the filter structure pointer instead of the RX ring number. This will allow an ntuple filter to be set up for the non-default RSS contexts in the next patch.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -2
@@ -5789,8 +5789,10 @@ void bnxt_fill_ipv6_mask(__be32 mask[4])static void bnxt_cfg_rfs_ring_tbl_idx (struct bnxt *bp,struct hwrm_cfa_ntuple_filter_alloc_input *req, -u16 rxq) +struct bnxt_ntuple_filter *fltr) { +u16 rxq = fltr->base.rxq; +if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) {struct bnxt_vnic_info *vnic;u32 enables;
@@ -5831,7 +5833,7 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, req->flags =cpu_to_le32 (CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DROP ); }else if (bp->fw_cap &BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2 ) { -bnxt_cfg_rfs_ring_tbl_idx (bp, req, fltr->base.rxq); +bnxt_cfg_rfs_ring_tbl_idx (bp, req, fltr); }else { vnic = &bp->vnic_info[fltr->base.rxq +1 ]; req->dst_id =cpu_to_le16 (vnic->fw_vnic_id);
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 12/12 bnxt_en: Support adding ntuple rules on RSS contexts
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
When the user wants to add an ntuple filter to an RSS context, select the appropriate VNIC belonging to the selected RSS context and add the VNIC destination rule.
Make the necessary changes to bnxt_add_ntuple_cls_rule().
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 +++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 33 ++++++++++++++----- 3 files changed, 51 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +26 -0
@@ -5791,8 +5791,20 @@ bnxt_cfg_rfs_ring_tbl_idx(struct bnxt *bp,struct hwrm_cfa_ntuple_filter_alloc_input *req, struct bnxt_ntuple_filter *fltr) { + struct bnxt_rss_ctx *rss_ctx, *tmp;u16 rxq = fltr->base.rxq; +if (fltr->base.flags &BNXT_ACT_RSS_CTX ) { +list_for_each_entry_safe (rss_ctx, tmp, &bp->rss_ctx_list, list) { +if (rss_ctx->index == fltr->base.fw_vnic_id) { +struct bnxt_vnic_info *vnic = &rss_ctx->vnic; + + req->dst_id =cpu_to_le16 (vnic->fw_vnic_id); +break ; + } + } +return ; + }if (BNXT_SUPPORTS_NTUPLE_VNIC (bp)) {struct bnxt_vnic_info *vnic;u32 enables;
@@ -9944,6 +9956,8 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, bool all) {struct bnxt_vnic_info *vnic = &rss_ctx->vnic; +struct bnxt_filter_base *usr_fltr, *tmp; +struct bnxt_ntuple_filter *ntp_fltr;int i;bnxt_hwrm_vnic_free_one (bp, &rss_ctx->vnic);
@@ -9954,6 +9968,18 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,if (!all)return ; +list_for_each_entry_safe (usr_fltr, tmp, &bp->usr_fltr_list, list) { +if ((usr_fltr->flags &BNXT_ACT_RSS_CTX ) && + usr_fltr->fw_vnic_id == rss_ctx->index) { + ntp_fltr =container_of (usr_fltr, + struct bnxt_ntuple_filter, + base); +bnxt_hwrm_cfa_ntuple_filter_free (bp, ntp_fltr); +bnxt_del_ntp_filter (bp, ntp_fltr); +bnxt_del_one_usr_fltr (bp, usr_fltr); + } + } +if (vnic->rss_table) dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size, vnic->rss_table,
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1374,6 +1374,7 @@ struct bnxt_filter_base {#define BNXT_ACT_RING_DST 2#define BNXT_ACT_FUNC_DST 4#define BNXT_ACT_NO_AGING 8 +#define BNXT_ACT_RSS_CTX 0x10u16 sw_id;u16 rxq;u16 fw_vnic_id;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +24 -9
@@ -1312,22 +1312,24 @@ static bool bnxt_verify_ntuple_ip6_flow(struct ethtool_usrip6_spec *ip_spec, }static int bnxt_add_ntuple_cls_rule (struct bnxt *bp, -struct ethtool_rx_flow_spec *fs) +struct ethtool_rxnfc *cmd) { -u8 vf =ethtool_get_flow_spec_ring_vf (fs->ring_cookie); -u32 ring =ethtool_get_flow_spec_ring (fs->ring_cookie); +struct ethtool_rx_flow_spec *fs = &cmd->fs;struct bnxt_ntuple_filter *new_fltr, *fltr; +u32 flow_type = fs->flow_type &0xff ;struct bnxt_l2_filter *l2_fltr;struct bnxt_flow_masks *fmasks; -u32 flow_type = fs->flow_type;struct flow_keys *fkeys; -u32 idx; +u32 idx, ring;int rc; +u8 vf;if (!bp->vnic_info)return -EAGAIN ; -if ((flow_type & (FLOW_MAC_EXT |FLOW_EXT )) || vf) + vf =ethtool_get_flow_spec_ring_vf (fs->ring_cookie); + ring =ethtool_get_flow_spec_ring (fs->ring_cookie); +if ((fs->flow_type & (FLOW_MAC_EXT |FLOW_EXT )) || vf)return -EOPNOTSUPP ;if (flow_type ==IP_USER_FLOW ) {
@@ -1435,6 +1437,19 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp,rcu_read_unlock (); new_fltr->base.flags =BNXT_ACT_NO_AGING ; +if (fs->flow_type &FLOW_RSS ) { +struct bnxt_rss_ctx *rss_ctx; + + new_fltr->base.fw_vnic_id =0 ; + new_fltr->base.flags |=BNXT_ACT_RSS_CTX ; + rss_ctx =bnxt_get_rss_ctx_from_index (bp, cmd->rss_context); +if (rss_ctx) { + new_fltr->base.fw_vnic_id = rss_ctx->index; + }else { + rc = -EINVAL ; + goto ntuple_err; + } + }if (fs->ring_cookie ==RX_CLS_FLOW_DISC ) new_fltr->base.flags |=BNXT_ACT_DROP ;else
@@ -1476,12 +1491,12 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd) flow_type == IPV6_USER_FLOW) && !(bp->fw_cap & BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO))return -EOPNOTSUPP ; -if (flow_type & (FLOW_MAC_EXT |FLOW_RSS )) +if (flow_type &FLOW_MAC_EXT )return -EINVAL ; flow_type &= ~FLOW_EXT ;if (fs->ring_cookie ==RX_CLS_FLOW_DISC && flow_type !=ETHER_FLOW ) -return bnxt_add_ntuple_cls_rule (bp, fs); +return bnxt_add_ntuple_cls_rule (bp, cmd); ring =ethtool_get_flow_spec_ring (fs->ring_cookie); vf =ethtool_get_flow_spec_ring_vf (fs->ring_cookie);
@@ -1495,7 +1510,7 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd)if (flow_type ==ETHER_FLOW ) rc =bnxt_add_l2_cls_rule (bp, fs);else - rc =bnxt_add_ntuple_cls_rule (bp, fs); + rc =bnxt_add_ntuple_cls_rule (bp, cmd);return rc; }
Signature · 1 line
2.30.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 25 Mar 2024 15:28:50 -0700 you wrote:
The first 2 patches are v2 of the PTP patches posted about 3 weeks ago:
https://lore.kernel.org/netdev/[email protected]/
The devlink parameter is dropped and v2 is just to increase the timeout accuracy and to use a default timeout of 1 second.
[...]
Here is the summary with links:
- [net-next,01/12] bnxt_en: Add a timeout parameter to bnxt_hwrm_port_ts_query()
https://git.kernel.org/netdev/net-next/c/7de3c2218eed - [net-next,02/12] bnxt_en: Retry PTP TX timestamp from FW for 1 second https://git.kernel.org/netdev/net-next/c/604041643a85 - [net-next,03/12] bnxt_en: Add helper function bnxt_hwrm_vnic_rss_cfg_p5() https://git.kernel.org/netdev/net-next/c/1dcd70ba2437 - [net-next,04/12] bnxt_en: Refactor VNIC alloc and cfg functions https://git.kernel.org/netdev/net-next/c/a4c11166a696 - [net-next,05/12] bnxt_en: Introduce rss ctx structure, alloc/free functions https://git.kernel.org/netdev/net-next/c/fea41bd76634 - [net-next,06/12] bnxt_en: Refactor RSS indir alloc/set functions https://git.kernel.org/netdev/net-next/c/ecb342bb6098 - [net-next,07/12] bnxt_en: Simplify bnxt_rfs_capable() https://git.kernel.org/netdev/net-next/c/b09353437b28 - [net-next,08/12] bnxt_en: Add a new_rss_ctx parameter to bnxt_rfs_capable() https://git.kernel.org/netdev/net-next/c/0895926f725a - [net-next,09/12] bnxt_en: Refactor bnxt_set_rxfh() https://git.kernel.org/netdev/net-next/c/77a614f7499e - [net-next,10/12] bnxt_en: Support RSS contexts in ethtool .{get|set}_rxfh() https://git.kernel.org/netdev/net-next/c/b3d0083caf9a - [net-next,11/12] bnxt_en: Refactor bnxt_cfg_rfs_ring_tbl_idx() https://git.kernel.org/netdev/net-next/c/61c814bf4ad7 - [net-next,12/12] bnxt_en: Support adding ntuple rules on RSS contexts https://git.kernel.org/netdev/net-next/c/2f4f9fe5bf5f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html