bnxt_en: Add TPA (GRO_HW and LRO) on 57500 chips.
Michael Chan
maintainercover bnxt_en: Add TPA (GRO_HW and LRO) on 57500 chips.
This patchset adds TPA v2 support on the 57500 chips. TPA v2 is different from the legacy TPA scheme on older chips and requires major refactoring and restructuring of the existing TPA logic. The main difference is that the new TPA v2 has on-the-fly aggregation buffer completions before a TPA packet is completed. The larger aggregation ID space also requires a new ID mapping logic to make it more memory efficient.
Michael Chan (16):
bnxt_en: Update firmware interface spec. to 1.10.0.89.
bnxt_en: Add TPA structure definitions for BCM57500 chips.
bnxt_en: Refactor TPA logic.
bnxt_en: Expand bnxt_tpa_info struct to support 57500 chips.
bnxt_en: Handle standalone RX_AGG completions.
bnxt_en: Refactor tunneled hardware GRO logic.
bnxt_en: Set TPA GRO mode flags on 57500 chips properly.
bnxt_en: Add fast path logic for TPA on 57500 chips.
bnxt_en: Add TPA ID mapping logic for 57500 chips.
bnxt_en: Add hardware GRO setup function for 57500 chips.
bnxt_en: Refactor ethtool ring statistics logic.
bnxt_en: Allocate the larger per-ring statistics block for 57500
chips.
bnxt_en: Support TPA counters on 57500 chips.
bnxt_en: Refactor bnxt_init_one() and turn on TPA support on 57500
chips.
bnxt_en: Support all variants of the 5750X chip family.
bnxt_en: Add PCI IDs for 57500 series NPAR devices.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 542 +++++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 95 +++- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 156 +++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 109 ++++- 4 files changed, 666 insertions(+), 236 deletions(-)
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 1/16 bnxt_en: Update firmware interface spec. to 1.10.0.89.
Among the changes are new CoS discard counters and new ctx_hw_stats_ext struct for the latest 5750X B0 chips.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 15 +++ drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 109 ++++++++++++++++++---- 2 files changed, 108 insertions(+), 16 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +15 -0
@@ -207,6 +207,20 @@ static int bnxt_set_coalesce(struct net_device *dev,BNXT_TX_STATS_EXT_COS_ENTRY (6 ), \ BNXT_TX_STATS_EXT_COS_ENTRY(7) \ +#define BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY (n) \ + BNXT_RX_STATS_EXT_ENTRY(rx_discard_bytes_cos##n), \ + BNXT_RX_STATS_EXT_ENTRY(rx_discard_packets_cos##n) + +#define BNXT_RX_STATS_EXT_DISCARD_COS_ENTRIES \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(0), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(1), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(2), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(3), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(4), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(5), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(6), \ + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(7) +#define BNXT_RX_STATS_PRI_ENTRY (counter, n) \ { BNXT_RX_STATS_EXT_OFFSET(counter##_cos0), \ __stringify(counter##_pri##n) }
@@ -352,6 +366,7 @@ static const struct {BNXT_RX_STATS_EXT_ENTRY (rx_buffer_passed_threshold),BNXT_RX_STATS_EXT_ENTRY (rx_pcs_symbol_err),BNXT_RX_STATS_EXT_ENTRY (rx_corrected_bits), + BNXT_RX_STATS_EXT_DISCARD_COS_ENTRIES, }; static const struct {
drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h +93 -16
241 lines not on this page · raw message
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 2/16 bnxt_en: Add TPA structure definitions for BCM57500 chips.
In reply to Michael ChanThe new chips have a slightly modified TPA interface for LRO/GRO_HW. Modify the TPA structures so that the same structures can also be used on the new chips.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +67 -0
@@ -113,6 +113,7 @@ struct tx_cmp {#define CMP_TYPE_RX_AGG_CMP 18#define CMP_TYPE_RX_L2_TPA_START_CMP 19#define CMP_TYPE_RX_L2_TPA_END_CMP 21 +#define CMP_TYPE_RX_TPA_AGG_CMP 22#define CMP_TYPE_STATUS_CMP 32#define CMP_TYPE_REMOTE_DRIVER_REQ 34#define CMP_TYPE_REMOTE_DRIVER_RESP 36
@@ -263,14 +264,21 @@ struct rx_agg_cmp {u32 rx_agg_cmp_opaque;__le32 rx_agg_cmp_v;#define RX_AGG_CMP_V (1 << 0) +#define RX_AGG_CMP_AGG_ID (0xffff << 16) +#define RX_AGG_CMP_AGG_ID_SHIFT 16__le32 rx_agg_cmp_unused; }; +#define TPA_AGG_AGG_ID (rx_agg) \ + ((le32_to_cpu((rx_agg)->rx_agg_cmp_v) & \ + RX_AGG_CMP_AGG_ID) >> RX_AGG_CMP_AGG_ID_SHIFT) +struct rx_tpa_start_cmp {__le32 rx_tpa_start_cmp_len_flags_type;#define RX_TPA_START_CMP_TYPE (0x3f << 0)#define RX_TPA_START_CMP_FLAGS (0x3ff << 6)#define RX_TPA_START_CMP_FLAGS_SHIFT 6 +#define RX_TPA_START_CMP_FLAGS_ERROR (0x1 << 6)#define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7)#define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7#define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
@@ -278,6 +286,7 @@ struct rx_tpa_start_cmp {#define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)#define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)#define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10) +#define RX_TPA_START_CMP_FLAGS_TIMESTAMP (0x1 << 11)#define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12)#define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12#define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
@@ -291,6 +300,8 @@ struct rx_tpa_start_cmp {#define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9#define RX_TPA_START_CMP_AGG_ID (0x7f << 25)#define RX_TPA_START_CMP_AGG_ID_SHIFT 25 +#define RX_TPA_START_CMP_AGG_ID_P5 (0xffff << 16) +#define RX_TPA_START_CMP_AGG_ID_SHIFT_P5 16__le32 rx_tpa_start_cmp_rss_hash; };
@@ -308,6 +319,14 @@ struct rx_tpa_start_cmp { ((le32_to_cpu ((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT) +#define TPA_START_AGG_ID_P5 (rx_tpa_start) \ + ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ + RX_TPA_START_CMP_AGG_ID_P5) >> RX_TPA_START_CMP_AGG_ID_SHIFT_P5) + +#define TPA_START_ERROR (rx_tpa_start) \ + ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \ + cpu_to_le32(RX_TPA_START_CMP_FLAGS_ERROR)) +struct rx_tpa_start_cmp_ext {__le32 rx_tpa_start_cmp_flags2;#define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0)
@@ -315,10 +334,20 @@ struct rx_tpa_start_cmp_ext {#define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)#define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)#define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8) +#define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_VALID (0x1 << 9) +#define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT (0x3 << 10) +#define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT_SHIFT 10 +#define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL (0xffff << 16) +#define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_SHIFT 16__le32 rx_tpa_start_cmp_metadata;__le32 rx_tpa_start_cmp_cfa_code_v2;#define RX_TPA_START_CMP_V2 (0x1 << 0) +#define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK (0x7 << 1) +#define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT 1 +#define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) +#define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) +#define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1)#define RX_TPA_START_CMP_CFA_CODE (0xffff << 16)#define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16__le32 rx_tpa_start_cmp_hdr_info;
@@ -332,6 +361,11 @@ struct rx_tpa_start_cmp_ext { (!!((rx_tpa_start)->rx_tpa_start_cmp_flags2 & \ cpu_to_le32(RX_TPA_START_CMP_FLAGS2_IP_TYPE))) +#define TPA_START_ERROR_CODE (rx_tpa_start) \ + ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ + RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK) >> \ + RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT) +struct rx_tpa_end_cmp {__le32 rx_tpa_end_cmp_len_flags_type;#define RX_TPA_END_CMP_TYPE (0x3f << 0)
@@ -361,6 +395,8 @@ struct rx_tpa_end_cmp {#define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16#define RX_TPA_END_CMP_AGG_ID (0x7f << 25)#define RX_TPA_END_CMP_AGG_ID_SHIFT 25 +#define RX_TPA_END_CMP_AGG_ID_P5 (0xffff << 16) +#define RX_TPA_END_CMP_AGG_ID_SHIFT_P5 16__le32 rx_tpa_end_cmp_tsdelta;#define RX_TPA_END_GRO_TS (0x1 << 31)
@@ -370,6 +406,18 @@ struct rx_tpa_end_cmp { ((le32_to_cpu ((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT) +#define TPA_END_AGG_ID_P5 (rx_tpa_end) \ + ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ + RX_TPA_END_CMP_AGG_ID_P5) >> RX_TPA_END_CMP_AGG_ID_SHIFT_P5) + +#define TPA_END_PAYLOAD_OFF (rx_tpa_end) \ + ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ + RX_TPA_END_CMP_PAYLOAD_OFFSET) >> RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT) + +#define TPA_END_AGG_BUFS (rx_tpa_end) \ + ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ + RX_TPA_END_CMP_AGG_BUFS) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT) +#define TPA_END_TPA_SEGS (rx_tpa_end) \ ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT)
@@ -389,6 +437,10 @@ struct rx_tpa_end_cmp {struct rx_tpa_end_cmp_ext {__le32 rx_tpa_end_cmp_dup_acks;#define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0) +#define RX_TPA_END_CMP_PAYLOAD_OFFSET_P5 (0xff << 16) +#define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5 16 +#define RX_TPA_END_CMP_AGG_BUFS_P5 (0xff << 24) +#define RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5 24__le32 rx_tpa_end_cmp_seg_len;#define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0)
@@ -396,7 +448,13 @@ struct rx_tpa_end_cmp_ext {__le32 rx_tpa_end_cmp_errors_v2;#define RX_TPA_END_CMP_V2 (0x1 << 0)#define RX_TPA_END_CMP_ERRORS (0x3 << 1) +#define RX_TPA_END_CMP_ERRORS_P5 (0x7 << 1)#define RX_TPA_END_CMPL_ERRORS_SHIFT 1 +#define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) +#define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1) +#define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) +#define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_RSV_ERROR (0x4 << 1) +#define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1)u32 rx_tpa_end_cmp_start_opaque; };
@@ -405,6 +463,15 @@ struct rx_tpa_end_cmp_ext { ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \ cpu_to_le32(RX_TPA_END_CMP_ERRORS)) +#define TPA_END_PAYLOAD_OFF_P5 (rx_tpa_end_ext) \ + ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \ + RX_TPA_END_CMP_PAYLOAD_OFFSET_P5) >> \ + RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5) + +#define TPA_END_AGG_BUFS_P5 (rx_tpa_end_ext) \ + ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \ + RX_TPA_END_CMP_AGG_BUFS_P5) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5) +struct nqe_cn {__le16 type;#define NQ_CN_TYPE_MASK 0x3fUL
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 3/16 bnxt_en: Refactor TPA logic.
In reply to Michael ChanRefactor the TPA logic slightly, so that the code can be more easily extended to support TPA on the new 57500 chips. In particular, the logic to get the next aggregation completion is refactored into a new function bnxt_get_agg() so that this operation is made more generalized. This operation will be different on the new chip in TPA mode. The logic to recycle the aggregation buffers has a new start index parameter added for the same purpose.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 117 ++++++++++++++++++------------ 1 file changed, 69 insertions(+), 48 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +69 -48
@@ -828,8 +828,20 @@ static inline int bnxt_alloc_rx_page(struct bnxt *bp,return 0 ; } -static void bnxt_reuse_rx_agg_bufs (struct bnxt_cp_ring_info *cpr,u16 cp_cons, -u32 agg_bufs) +static struct rx_agg_cmp *bnxt_get_agg (struct bnxt *bp, +struct bnxt_cp_ring_info *cpr, +u16 cp_cons,u16 curr) +{ +struct rx_agg_cmp *agg; + + cp_cons =RING_CMP (ADV_RAW_CMP (cp_cons, curr)); + agg = (struct rx_agg_cmp *) + &cpr->cp_desc_ring[CP_RING (cp_cons)][CP_IDX (cp_cons)]; +return agg; +} + +static void bnxt_reuse_rx_agg_bufs (struct bnxt_cp_ring_info *cpr,u16 idx, +u16 start,u32 agg_bufs,bool tpa) {struct bnxt_napi *bnapi = cpr->bnapi;struct bnxt *bp = bnapi->bp;
@@ -845,8 +857,7 @@ static void bnxt_reuse_rx_agg_bufs(struct bnxt_cp_ring_info *cpr, u16 cp_cons,struct rx_bd *prod_bd;struct page *page; - agg = (struct rx_agg_cmp *) - &cpr->cp_desc_ring[CP_RING (cp_cons)][CP_IDX (cp_cons)]; + agg =bnxt_get_agg (bp, cpr, idx, start + i); cons = agg->rx_agg_cmp_opaque;__clear_bit (cons, rxr->rx_agg_bmap);
@@ -874,7 +885,6 @@ static void bnxt_reuse_rx_agg_bufs(struct bnxt_cp_ring_info *cpr, u16 cp_cons, prod =NEXT_RX_AGG (prod); sw_prod =NEXT_RX_AGG (sw_prod); - cp_cons =NEXT_CMP (cp_cons); } rxr->rx_agg_prod = prod; rxr->rx_sw_agg_prod = sw_prod;
@@ -957,8 +967,8 @@ static struct sk_buff *bnxt_rx_skb(struct bnxt *bp,static struct sk_buff *bnxt_rx_pages (struct bnxt *bp,struct bnxt_cp_ring_info *cpr, -struct sk_buff *skb,u16 cp_cons, -u32 agg_bufs) +struct sk_buff *skb,u16 idx, +u32 agg_bufs,bool tpa) {struct bnxt_napi *bnapi = cpr->bnapi;struct pci_dev *pdev = bp->pdev;
@@ -973,8 +983,7 @@ static struct sk_buff *bnxt_rx_pages(struct bnxt *bp,struct page *page;dma_addr_t mapping; - agg = (struct rx_agg_cmp *) - &cpr->cp_desc_ring[CP_RING (cp_cons)][CP_IDX (cp_cons)]; + agg =bnxt_get_agg (bp, cpr, idx, i); cons = agg->rx_agg_cmp_opaque; frag_len = (le32_to_cpu (agg->rx_agg_cmp_len_flags_type) &RX_AGG_CMP_LEN ) >>RX_AGG_CMP_LEN_SHIFT ;
@@ -1008,7 +1017,7 @@ static struct sk_buff *bnxt_rx_pages(struct bnxt *bp,* allocated already. */ rxr->rx_agg_prod = prod; -bnxt_reuse_rx_agg_bufs (cpr, cp_cons, agg_bufs - i); +bnxt_reuse_rx_agg_bufs (cpr, idx, i, agg_bufs - i, tpa);return NULL ; }
@@ -1021,7 +1030,6 @@ static struct sk_buff *bnxt_rx_pages(struct bnxt *bp, skb->truesize +=PAGE_SIZE ; prod =NEXT_RX_AGG (prod); - cp_cons =NEXT_CMP (cp_cons); } rxr->rx_agg_prod = prod;return skb;
@@ -1081,9 +1089,7 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, }else if (cmp_type ==CMP_TYPE_RX_L2_TPA_END_CMP ) {struct rx_tpa_end_cmp *tpa_end = cmp; - agg_bufs = (le32_to_cpu (tpa_end->rx_tpa_end_cmp_misc_v1) & -RX_TPA_END_CMP_AGG_BUFS ) >> -RX_TPA_END_CMP_AGG_BUFS_SHIFT ; + agg_bufs =TPA_END_AGG_BUFS (tpa_end); }if (agg_bufs) {
@@ -1195,11 +1201,10 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, cons_rx_buf->data =NULL ; } -static void bnxt_abort_tpa (struct bnxt_cp_ring_info *cpr,u16 cp_cons, -u32 agg_bufs) +static void bnxt_abort_tpa (struct bnxt_cp_ring_info *cpr,u16 idx,u32 agg_bufs) {if (agg_bufs) -bnxt_reuse_rx_agg_bufs (cpr, cp_cons, agg_bufs); +bnxt_reuse_rx_agg_bufs (cpr, idx,0 , agg_bufs, true); } static struct sk_buff *bnxt_gro_func_5731x(struct bnxt_tpa_info *tpa_info,
@@ -1371,9 +1376,7 @@ static inline struct sk_buff *bnxt_gro_skb(struct bnxt *bp,skb_shinfo (skb)->gso_size =le32_to_cpu (tpa_end1->rx_tpa_end_cmp_seg_len);skb_shinfo (skb)->gso_type = tpa_info->gso_type; - payload_off = (le32_to_cpu (tpa_end->rx_tpa_end_cmp_misc_v1) & -RX_TPA_END_CMP_PAYLOAD_OFFSET ) >> -RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT ; + payload_off =TPA_END_PAYLOAD_OFF (tpa_end); skb = bp->gro_func (tpa_info, payload_off,TPA_END_GRO_TS (tpa_end), skb);if (likely (skb))tcp_gro_complete (skb);
@@ -1403,11 +1406,11 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,struct bnxt_rx_ring_info *rxr = bnapi->rx_ring;u8 agg_id =TPA_END_AGG_ID (tpa_end);u8 *data_ptr, agg_bufs; -u16 cp_cons =RING_CMP (*raw_cons);unsigned int len;struct bnxt_tpa_info *tpa_info;dma_addr_t mapping;struct sk_buff *skb; +u16 idx =0 ;void *data;if (unlikely (bnapi->in_reset)) {
@@ -1425,19 +1428,19 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, len = tpa_info->len; mapping = tpa_info->mapping; - agg_bufs = (le32_to_cpu (tpa_end->rx_tpa_end_cmp_misc_v1) & -RX_TPA_END_CMP_AGG_BUFS ) >>RX_TPA_END_CMP_AGG_BUFS_SHIFT ; + agg_bufs =TPA_END_AGG_BUFS (tpa_end);if (agg_bufs) { + idx =RING_CMP (*raw_cons);if (!bnxt_agg_bufs_valid (bp, cpr, agg_bufs, raw_cons))return ERR_PTR (-EBUSY ); *event |=BNXT_AGG_EVENT ; - cp_cons =NEXT_CMP (cp_cons); + idx =NEXT_CMP (idx); }if (unlikely (agg_bufs >MAX_SKB_FRAGS ||TPA_END_ERRORS (tpa_end1))) { -bnxt_abort_tpa (cpr, cp_cons, agg_bufs); +bnxt_abort_tpa (cpr, idx, agg_bufs);if (agg_bufs >MAX_SKB_FRAGS )netdev_warn (bp->dev,"TPA frags %d exceeded MAX_SKB_FRAGS %d\n" , agg_bufs, (int )MAX_SKB_FRAGS );
@@ -1447,7 +1450,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,if (len <= bp->rx_copy_thresh) { skb =bnxt_copy_skb (bnapi, data_ptr, len, mapping);if (!skb) { -bnxt_abort_tpa (cpr, cp_cons, agg_bufs); +bnxt_abort_tpa (cpr, idx, agg_bufs);return NULL ; } }else {
@@ -1456,7 +1459,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, new_data =__bnxt_alloc_rx_data (bp, &new_mapping,GFP_ATOMIC );if (!new_data) { -bnxt_abort_tpa (cpr, cp_cons, agg_bufs); +bnxt_abort_tpa (cpr, idx, agg_bufs);return NULL ; }
@@ -1471,7 +1474,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,if (!skb) {kfree (data); -bnxt_abort_tpa (cpr, cp_cons, agg_bufs); +bnxt_abort_tpa (cpr, idx, agg_bufs);return NULL ; }skb_reserve (skb, bp->rx_offset);
@@ -1479,7 +1482,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, }if (agg_bufs) { - skb =bnxt_rx_pages (bp, cpr, skb, cp_cons, agg_bufs); + skb =bnxt_rx_pages (bp, cpr, skb, idx, agg_bufs, true);if (!skb) {/* Page reuse already handled by bnxt_rx_pages(). */ return NULL ;
@@ -1623,7 +1626,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bnxt_reuse_rx_data (rxr, cons, data);if (agg_bufs) -bnxt_reuse_rx_agg_bufs (cpr, cp_cons, agg_bufs); +bnxt_reuse_rx_agg_bufs (cpr, cp_cons,0 , agg_bufs, + false); rc = -EIO ;if (rx_err &RX_CMPL_ERRORS_BUFFER_ERROR_MASK ) {
@@ -1646,7 +1650,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bnxt_reuse_rx_data (rxr, cons, data);if (!skb) {if (agg_bufs) -bnxt_reuse_rx_agg_bufs (cpr, cp_cons, agg_bufs); +bnxt_reuse_rx_agg_bufs (cpr, cp_cons,0 , + agg_bufs, false); rc = -ENOMEM ; goto next_rx; }
@@ -1666,7 +1671,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, }if (agg_bufs) { - skb =bnxt_rx_pages (bp, cpr, skb, cp_cons, agg_bufs); + skb =bnxt_rx_pages (bp, cpr, skb, cp_cons, agg_bufs, false);if (!skb) { rc = -ENOMEM ; goto next_rx;
@@ -2483,6 +2488,33 @@ static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)return 0 ; } +static void bnxt_free_tpa_info (struct bnxt *bp) +{ +int i; + +for (i =0 ; i < bp->rx_nr_rings; i++) { +struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; + +kfree (rxr->rx_tpa); + rxr->rx_tpa =NULL ; + } +} + +static int bnxt_alloc_tpa_info (struct bnxt *bp) +{ +int i; + +for (i =0 ; i < bp->rx_nr_rings; i++) { +struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; + + rxr->rx_tpa =kcalloc (MAX_TPA ,sizeof (struct bnxt_tpa_info ), +GFP_KERNEL ); +if (!rxr->rx_tpa) +return -ENOMEM ; + } +return 0 ; +} +static void bnxt_free_rx_rings (struct bnxt *bp) {int i;
@@ -2490,6 +2522,7 @@ static void bnxt_free_rx_rings(struct bnxt *bp)if (!bp->rx_ring)return ; +bnxt_free_tpa_info (bp);for (i =0 ; i < bp->rx_nr_rings; i++) {struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];struct bnxt_ring_struct *ring;
@@ -2503,9 +2536,6 @@ static void bnxt_free_rx_rings(struct bnxt *bp)page_pool_destroy (rxr->page_pool); rxr->page_pool =NULL ; -kfree (rxr->rx_tpa); - rxr->rx_tpa =NULL ; -kfree (rxr->rx_agg_bmap); rxr->rx_agg_bmap =NULL ;
@@ -2539,7 +2569,7 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,static int bnxt_alloc_rx_rings (struct bnxt *bp) { -int i, rc, agg_rings =0 , tpa_rings =0 ; +int i, rc =0 , agg_rings =0 ;if (!bp->rx_ring)return -ENOMEM ;
@@ -2547,9 +2577,6 @@ static int bnxt_alloc_rx_rings(struct bnxt *bp)if (bp->flags &BNXT_FLAG_AGG_RINGS ) agg_rings =1 ; -if (bp->flags &BNXT_FLAG_TPA ) - tpa_rings =1 ; -for (i =0 ; i < bp->rx_nr_rings; i++) {struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];struct bnxt_ring_struct *ring;
@@ -2591,17 +2618,11 @@ static int bnxt_alloc_rx_rings(struct bnxt *bp) rxr->rx_agg_bmap =kzalloc (mem_size,GFP_KERNEL );if (!rxr->rx_agg_bmap)return -ENOMEM ; - -if (tpa_rings) { - rxr->rx_tpa =kcalloc (MAX_TPA , -sizeof (struct bnxt_tpa_info ), -GFP_KERNEL ); -if (!rxr->rx_tpa) -return -ENOMEM ; - } } } -return 0 ; +if (bp->flags &BNXT_FLAG_TPA ) + rc =bnxt_alloc_tpa_info (bp); +return rc; }static void bnxt_free_tx_rings (struct bnxt *bp)
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 4/16 bnxt_en: Expand bnxt_tpa_info struct to support 57500 chips.
In reply to Michael ChanAdd an aggregation array to bnxt_tpa_info struct to keep track of the aggregation completions. The aggregation completions are not completed at the TPA_END completion on 57500 chips so we need to keep track of them. The array is only allocated on the new chips when required. An agg_count field is also added to keep track of the number of these completions.
The maximum concurrent TPA is now discovered from firmware instead of the hardcoded 64. Add a new bp->max_tpa to keep track of maximum configured TPA.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 41 ++++++++++++++++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 6 +++++ 2 files changed, 41 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +35 -6
@@ -2333,7 +2333,7 @@ static void bnxt_free_rx_skbs(struct bnxt *bp)int j;if (rxr->rx_tpa) { -for (j =0 ; j <MAX_TPA ; j++) { +for (j =0 ; j < bp->max_tpa; j++) {struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[j];u8 *data = tpa_info->data;
@@ -2495,6 +2495,10 @@ static void bnxt_free_tpa_info(struct bnxt *bp)for (i =0 ; i < bp->rx_nr_rings; i++) {struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; +if (rxr->rx_tpa) { +kfree (rxr->rx_tpa[0 ].agg_arr); + rxr->rx_tpa[0 ].agg_arr =NULL ; + }kfree (rxr->rx_tpa); rxr->rx_tpa =NULL ; }
@@ -2502,15 +2506,33 @@ static void bnxt_free_tpa_info(struct bnxt *bp)static int bnxt_alloc_tpa_info (struct bnxt *bp) { -int i; +int i, j, total_aggs =0 ; + + bp->max_tpa =MAX_TPA ; +if (bp->flags &BNXT_FLAG_CHIP_P5 ) { +if (!bp->max_tpa_v2) +return 0 ; + bp->max_tpa =max_t (u16, bp->max_tpa_v2,MAX_TPA_P5 ); + total_aggs = bp->max_tpa *MAX_SKB_FRAGS ; + }for (i =0 ; i < bp->rx_nr_rings; i++) {struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; +struct rx_agg_cmp *agg; - rxr->rx_tpa =kcalloc (MAX_TPA ,sizeof (struct bnxt_tpa_info ), + rxr->rx_tpa =kcalloc (bp->max_tpa,sizeof (struct bnxt_tpa_info ),GFP_KERNEL );if (!rxr->rx_tpa)return -ENOMEM ; + +if (!(bp->flags &BNXT_FLAG_CHIP_P5 )) +continue ; + agg =kcalloc (total_aggs,sizeof (*agg),GFP_KERNEL ); + rxr->rx_tpa[0 ].agg_arr = agg; +if (!agg) +return -ENOMEM ; +for (j =1 ; j < bp->max_tpa; j++) + rxr->rx_tpa[j].agg_arr = agg + j *MAX_SKB_FRAGS ; }return 0 ; }
@@ -2974,7 +2996,7 @@ static int bnxt_init_one_rx_ring(struct bnxt *bp, int ring_nr)u8 *data;dma_addr_t mapping; -for (i =0 ; i <MAX_TPA ; i++) { +for (i =0 ; i < bp->max_tpa; i++) { data =__bnxt_alloc_rx_data (bp, &mapping,GFP_KERNEL );if (!data)
@@ -4435,6 +4457,7 @@ static int bnxt_hwrm_clear_vnic_filter(struct bnxt *bp)static int bnxt_hwrm_vnic_set_tpa (struct bnxt *bp,u16 vnic_id,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 = {0 };if (vnic->fw_vnic_id ==INVALID_HW_RING_ID )
@@ -4474,9 +4497,14 @@ static int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, u16 vnic_id, u32 tpa_flags) nsegs = (MAX_SKB_FRAGS - n) / n; } - segs =ilog2 (nsegs); +if (bp->flags &BNXT_FLAG_CHIP_P5 ) { + segs =MAX_TPA_SEGS_P5 ; + max_aggs = bp->max_tpa; + }else { + segs =ilog2 (nsegs); + } req.max_agg_segs =cpu_to_le16 (segs); - req.max_aggs =cpu_to_le16 (VNIC_TPA_CFG_REQ_MAX_AGGS_MAX ); + req.max_aggs =cpu_to_le16 (max_aggs); req.min_agg_len =cpu_to_le32 (512 ); }
@@ -4836,6 +4864,7 @@ static int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)if (flags &VNIC_QCAPS_RESP_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_CAP ) bp->flags |=BNXT_FLAG_ROCE_MIRROR_CAP ; + bp->max_tpa_v2 =le16_to_cpu (resp->max_aggs_supported); }mutex_unlock (&bp->hwrm_cmd_lock);return rc;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +6 -0
@@ -554,6 +554,8 @@ struct nqe_cn {#define BNXT_DEFAULT_TX_RING_SIZE 511#define MAX_TPA 64 +#define MAX_TPA_P5 256 +#define MAX_TPA_SEGS_P5 0x3f#if (BNXT_PAGE_SHIFT ==16 )#define MAX_RX_PAGES 1
@@ -835,6 +837,8 @@ struct bnxt_tpa_info { ((hdr_info) & 0x1ff)u16 cfa_code;/* cfa_code in TPA start compl */ +u8 agg_count; +struct rx_agg_cmp *agg_arr; };struct bnxt_rx_ring_info {
@@ -1481,6 +1485,8 @@ struct bnxt { u16, void *, u8 *, dma_addr_t, unsigned int); +u16 max_tpa_v2; +u16 max_tpa;u32 rx_buf_size;u32 rx_buf_use_size;/* useable size */ u16 rx_offset;
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 5/16 bnxt_en: Handle standalone RX_AGG completions.
In reply to Michael ChanOn the new 57500 chips, these new RX_AGG completions are not coalesced at the TPA_END completion. Handle these by storing them in the array in the bnxt_tpa_info struct, as they are seen when processing the CMPL ring.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +18 -2
@@ -1517,6 +1517,17 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,return skb; } +static void bnxt_tpa_agg (struct bnxt *bp,struct bnxt_rx_ring_info *rxr, +struct rx_agg_cmp *rx_agg) +{ +u16 agg_id =TPA_AGG_AGG_ID (rx_agg); +struct bnxt_tpa_info *tpa_info; + + tpa_info = &rxr->rx_tpa[agg_id]; +BUG_ON (tpa_info->agg_count >=MAX_SKB_FRAGS ); + tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg; +} +static void bnxt_deliver_skb (struct bnxt *bp,struct bnxt_napi *bnapi,struct sk_buff *skb) {
@@ -1558,6 +1569,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, rxcmp = (struct rx_cmp *) &cpr->cp_desc_ring[CP_RING (cp_cons)][CP_IDX (cp_cons)]; + cmp_type =RX_CMP_TYPE (rxcmp); + +if (cmp_type ==CMP_TYPE_RX_TPA_AGG_CMP ) { +bnxt_tpa_agg (bp, rxr, (struct rx_agg_cmp *)rxcmp); + goto next_rx_no_prod_no_len; + } + tmp_raw_cons =NEXT_RAW_CMP (tmp_raw_cons); cp_cons =RING_CMP (tmp_raw_cons); rxcmp1 = (struct rx_cmp_ext *)
@@ -1566,8 +1584,6 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,if (!RX_CMP_VALID (rxcmp1, tmp_raw_cons))return -EBUSY ; - cmp_type =RX_CMP_TYPE (rxcmp); - prod = rxr->rx_prod;if (cmp_type ==CMP_TYPE_RX_L2_TPA_START_CMP ) {
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 6/16 bnxt_en: Refactor tunneled hardware GRO logic.
In reply to Michael ChanThe 2 GRO functions to set up the hardware GRO SKB fields for 2 different hardware chips have practically identical logic for tunneled packets. Refactor the logic into a separate bnxt_gro_tunnel() function that can be used by both functions.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 69 +++++++++++++------------------ 1 file changed, 28 insertions(+), 41 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +28 -41
@@ -1207,6 +1207,31 @@ static void bnxt_abort_tpa(struct bnxt_cp_ring_info *cpr, u16 idx, u32 agg_bufs)bnxt_reuse_rx_agg_bufs (cpr, idx,0 , agg_bufs, true); } +#ifdef CONFIG_INET +static void bnxt_gro_tunnel (struct sk_buff *skb,__be16 ip_proto) +{ +struct udphdr *uh =NULL ; + +if (ip_proto ==htons (ETH_P_IP )) { +struct iphdr *iph = (struct iphdr *)skb->data; + +if (iph->protocol ==IPPROTO_UDP ) + uh = (struct udphdr *)(iph +1 ); + }else { +struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; + +if (iph->nexthdr ==IPPROTO_UDP ) + uh = (struct udphdr *)(iph +1 ); + } +if (uh) { +if (uh->check) +skb_shinfo (skb)->gso_type |=SKB_GSO_UDP_TUNNEL_CSUM ; +else +skb_shinfo (skb)->gso_type |=SKB_GSO_UDP_TUNNEL ; + } +} +#endif +static struct sk_buff *bnxt_gro_func_5731x (struct bnxt_tpa_info *tpa_info,int payload_off,int tcp_ts,struct sk_buff *skb)
@@ -1264,28 +1289,10 @@ static struct sk_buff *bnxt_gro_func_5731x(struct bnxt_tpa_info *tpa_info, }if (inner_mac_off) {/* tunnel */ -struct udphdr *uh =NULL ;__be16 proto = *((__be16 *)(skb->data + outer_ip_off -ETH_HLEN -2 )); -if (proto ==htons (ETH_P_IP )) { -struct iphdr *iph = (struct iphdr *)skb->data; - -if (iph->protocol ==IPPROTO_UDP ) - uh = (struct udphdr *)(iph +1 ); - }else { -struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; - -if (iph->nexthdr ==IPPROTO_UDP ) - uh = (struct udphdr *)(iph +1 ); - } -if (uh) { -if (uh->check) -skb_shinfo (skb)->gso_type |= -SKB_GSO_UDP_TUNNEL_CSUM ; -else -skb_shinfo (skb)->gso_type |=SKB_GSO_UDP_TUNNEL ; - } +bnxt_gro_tunnel (skb, proto); }#endif return skb;
@@ -1332,28 +1339,8 @@ static struct sk_buff *bnxt_gro_func_5730x(struct bnxt_tpa_info *tpa_info, return NULL; } -if (nw_off) {/* tunnel */ -struct udphdr *uh =NULL ; - -if (skb->protocol ==htons (ETH_P_IP )) { -struct iphdr *iph = (struct iphdr *)skb->data; - -if (iph->protocol ==IPPROTO_UDP ) - uh = (struct udphdr *)(iph +1 ); - }else { -struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; - -if (iph->nexthdr ==IPPROTO_UDP ) - uh = (struct udphdr *)(iph +1 ); - } -if (uh) { -if (uh->check) -skb_shinfo (skb)->gso_type |= -SKB_GSO_UDP_TUNNEL_CSUM ; -else -skb_shinfo (skb)->gso_type |=SKB_GSO_UDP_TUNNEL ; - } - } +if (nw_off)/* tunnel */ +bnxt_gro_tunnel (skb, skb->protocol);#endif return skb; }
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 7/16 bnxt_en: Set TPA GRO mode flags on 57500 chips properly.
In reply to Michael ChanOn 57500 chips, hardware GRO mode cannot be determined from the TPA end, so we need to check bp->flags to determine if we are in hardware GRO mode or not. Modify bnxt_set_features so that the TPA flags in bp->flags don't change until the device is closed. This will ensure that the fast path can safely rely on bp->flags to determine the TPA mode.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -3
@@ -9345,7 +9345,8 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features)if (changes &BNXT_FLAG_TPA ) { update_tpa = true;if ((bp->flags &BNXT_FLAG_TPA ) ==0 || - (flags &BNXT_FLAG_TPA ) ==0 ) + (flags &BNXT_FLAG_TPA ) ==0 || + (bp->flags &BNXT_FLAG_CHIP_P5 )) re_init = true; }
@@ -9355,9 +9356,8 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features)if (flags != bp->flags) {u32 old_flags = bp->flags; - bp->flags = flags; -if (!test_bit (BNXT_STATE_OPEN , &bp->state)) { + bp->flags = flags;if (update_tpa)bnxt_set_ring_params (bp);return rc;
@@ -9365,12 +9365,14 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features)if (re_init) {bnxt_close_nic (bp, false, false); + bp->flags = flags;if (update_tpa)bnxt_set_ring_params (bp);return bnxt_open_nic (bp, false, false); }if (update_tpa) { + bp->flags = flags; rc =bnxt_set_tpa (bp, (flags &BNXT_FLAG_TPA ) ? true : false);
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 8/16 bnxt_en: Add fast path logic for TPA on 57500 chips.
In reply to Michael ChanWith all the previous refactoring, the TPA fast path can now be modified slightly to support TPA on the new chips. The main difference is that the agg completions are retrieved differently using the bnxt_get_tpa_agg_p5() function on the new chips.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 100 ++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 25 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +75 -25
@@ -840,6 +840,15 @@ static struct rx_agg_cmp *bnxt_get_agg(struct bnxt *bp,return agg; } +static struct rx_agg_cmp *bnxt_get_tpa_agg_p5 (struct bnxt *bp, +struct bnxt_rx_ring_info *rxr, +u16 agg_id,u16 curr) +{ +struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[agg_id]; + +return &tpa_info->agg_arr[curr]; +} +static void bnxt_reuse_rx_agg_bufs (struct bnxt_cp_ring_info *cpr,u16 idx,u16 start,u32 agg_bufs,bool tpa) {
@@ -848,8 +857,12 @@ static void bnxt_reuse_rx_agg_bufs(struct bnxt_cp_ring_info *cpr, u16 idx,struct bnxt_rx_ring_info *rxr = bnapi->rx_ring;u16 prod = rxr->rx_agg_prod;u16 sw_prod = rxr->rx_sw_agg_prod; +bool p5_tpa = false;u32 i; +if ((bp->flags &BNXT_FLAG_CHIP_P5 ) && tpa) + p5_tpa = true; +for (i =0 ; i < agg_bufs; i++) {u16 cons;struct rx_agg_cmp *agg;
@@ -857,7 +870,10 @@ static void bnxt_reuse_rx_agg_bufs(struct bnxt_cp_ring_info *cpr, u16 idx,struct rx_bd *prod_bd;struct page *page; - agg =bnxt_get_agg (bp, cpr, idx, start + i); +if (p5_tpa) + agg =bnxt_get_tpa_agg_p5 (bp, rxr, idx, start + i); +else + agg =bnxt_get_agg (bp, cpr, idx, start + i); cons = agg->rx_agg_cmp_opaque;__clear_bit (cons, rxr->rx_agg_bmap);
@@ -974,8 +990,12 @@ static struct sk_buff *bnxt_rx_pages(struct bnxt *bp,struct pci_dev *pdev = bp->pdev;struct bnxt_rx_ring_info *rxr = bnapi->rx_ring;u16 prod = rxr->rx_agg_prod; +bool p5_tpa = false;u32 i; +if ((bp->flags &BNXT_FLAG_CHIP_P5 ) && tpa) + p5_tpa = true; +for (i =0 ; i < agg_bufs; i++) {u16 cons, frag_len;struct rx_agg_cmp *agg;
@@ -983,7 +1003,10 @@ static struct sk_buff *bnxt_rx_pages(struct bnxt *bp,struct page *page;dma_addr_t mapping; - agg =bnxt_get_agg (bp, cpr, idx, i); +if (p5_tpa) + agg =bnxt_get_tpa_agg_p5 (bp, rxr, idx, i); +else + agg =bnxt_get_agg (bp, cpr, idx, i); cons = agg->rx_agg_cmp_opaque; frag_len = (le32_to_cpu (agg->rx_agg_cmp_len_flags_type) &RX_AGG_CMP_LEN ) >>RX_AGG_CMP_LEN_SHIFT ;
@@ -1089,6 +1112,9 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, }else if (cmp_type ==CMP_TYPE_RX_L2_TPA_END_CMP ) {struct rx_tpa_end_cmp *tpa_end = cmp; +if (bp->flags &BNXT_FLAG_CHIP_P5 ) +return 0 ; + agg_bufs =TPA_END_AGG_BUFS (tpa_end); }
@@ -1130,22 +1156,27 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,struct rx_tpa_start_cmp *tpa_start, struct rx_tpa_start_cmp_ext *tpa_start1) { - u8 agg_id = TPA_START_AGG_ID(tpa_start); -u16 cons, prod; -struct bnxt_tpa_info *tpa_info; struct bnxt_sw_rx_bd *cons_rx_buf, *prod_rx_buf; +struct bnxt_tpa_info *tpa_info; +u16 cons, prod, agg_id;struct rx_bd *prod_bd;dma_addr_t mapping; +if (bp->flags &BNXT_FLAG_CHIP_P5 ) + agg_id =TPA_START_AGG_ID_P5 (tpa_start); +else + agg_id =TPA_START_AGG_ID (tpa_start); cons = tpa_start->rx_tpa_start_cmp_opaque; prod = rxr->rx_prod; cons_rx_buf = &rxr->rx_buf_ring[cons]; prod_rx_buf = &rxr->rx_buf_ring[prod]; tpa_info = &rxr->rx_tpa[agg_id]; -if (unlikely (cons != rxr->rx_next_cons)) { -netdev_warn (bp->dev,"TPA cons %x != expected cons %x\n" , - cons, rxr->rx_next_cons); +if (unlikely (cons != rxr->rx_next_cons || +TPA_START_ERROR (tpa_start))) { +netdev_warn (bp->dev,"TPA cons %x, expected cons %x, error code %x\n" , + cons, rxr->rx_next_cons, +TPA_START_ERROR_CODE (tpa_start1));bnxt_sched_reset (bp, rxr);return ; }
@@ -1190,6 +1221,7 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, tpa_info->flags2 =le32_to_cpu (tpa_start1->rx_tpa_start_cmp_flags2); tpa_info->metadata =le32_to_cpu (tpa_start1->rx_tpa_start_cmp_metadata); tpa_info->hdr_info =le32_to_cpu (tpa_start1->rx_tpa_start_cmp_hdr_info); + tpa_info->agg_count =0 ; rxr->rx_prod =NEXT_RX (prod); cons =NEXT_RX (cons);
@@ -1363,7 +1395,10 @@ static inline struct sk_buff *bnxt_gro_skb(struct bnxt *bp,skb_shinfo (skb)->gso_size =le32_to_cpu (tpa_end1->rx_tpa_end_cmp_seg_len);skb_shinfo (skb)->gso_type = tpa_info->gso_type; - payload_off =TPA_END_PAYLOAD_OFF (tpa_end); +if (bp->flags &BNXT_FLAG_CHIP_P5 ) + payload_off =TPA_END_PAYLOAD_OFF_P5 (tpa_end1); +else + payload_off =TPA_END_PAYLOAD_OFF (tpa_end); skb = bp->gro_func (tpa_info, payload_off,TPA_END_GRO_TS (tpa_end), skb);if (likely (skb))tcp_gro_complete (skb);
@@ -1391,14 +1426,14 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, {struct bnxt_napi *bnapi = cpr->bnapi;struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; -u8 agg_id =TPA_END_AGG_ID (tpa_end);u8 *data_ptr, agg_bufs;unsigned int len;struct bnxt_tpa_info *tpa_info;dma_addr_t mapping;struct sk_buff *skb; -u16 idx =0 ; +u16 idx =0 , agg_id;void *data; +bool gro;if (unlikely (bnapi->in_reset)) {int rc =bnxt_discard_rx (bp, cpr, raw_cons, tpa_end);
@@ -1408,24 +1443,39 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,return NULL ; } - tpa_info = &rxr->rx_tpa[agg_id]; +if (bp->flags &BNXT_FLAG_CHIP_P5 ) { + agg_id =TPA_END_AGG_ID_P5 (tpa_end); + agg_bufs =TPA_END_AGG_BUFS_P5 (tpa_end1); + tpa_info = &rxr->rx_tpa[agg_id]; +if (unlikely (agg_bufs != tpa_info->agg_count)) { +netdev_warn (bp->dev,"TPA end agg_buf %d != expected agg_bufs %d\n" , + agg_bufs, tpa_info->agg_count); + agg_bufs = tpa_info->agg_count; + } + tpa_info->agg_count =0 ; + *event |=BNXT_AGG_EVENT ; + idx = agg_id; + gro = !!(bp->flags &BNXT_FLAG_GRO ); + }else { + agg_id =TPA_END_AGG_ID (tpa_end); + agg_bufs =TPA_END_AGG_BUFS (tpa_end); + tpa_info = &rxr->rx_tpa[agg_id]; + idx =RING_CMP (*raw_cons); +if (agg_bufs) { +if (!bnxt_agg_bufs_valid (bp, cpr, agg_bufs, raw_cons)) +return ERR_PTR (-EBUSY ); + + *event |=BNXT_AGG_EVENT ; + idx =NEXT_CMP (idx); + } + gro = !!TPA_END_GRO (tpa_end); + } data = tpa_info->data; data_ptr = tpa_info->data_ptr;prefetch (data_ptr); len = tpa_info->len; mapping = tpa_info->mapping; - agg_bufs =TPA_END_AGG_BUFS (tpa_end); - -if (agg_bufs) { - idx =RING_CMP (*raw_cons); -if (!bnxt_agg_bufs_valid (bp, cpr, agg_bufs, raw_cons)) -return ERR_PTR (-EBUSY ); - - *event |=BNXT_AGG_EVENT ; - idx =NEXT_CMP (idx); - } -if (unlikely (agg_bufs >MAX_SKB_FRAGS ||TPA_END_ERRORS (tpa_end1))) {bnxt_abort_tpa (cpr, idx, agg_bufs);if (agg_bufs >MAX_SKB_FRAGS )
@@ -1498,7 +1548,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, (tpa_info->flags2 &RX_CMP_FLAGS2_T_L4_CS_CALC ) >>3 ; } -if (TPA_END_GRO (tpa_end)) +if (gro) skb =bnxt_gro_skb (bp, tpa_info, tpa_end, tpa_end1, skb);return skb;
@@ -10785,7 +10835,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)#endif if (BNXT_SUPPORTS_TPA (bp)) { bp->gro_func = bnxt_gro_func_5730x; -if (BNXT_CHIP_P4 (bp)) +if (BNXT_CHIP_P4_PLUS (bp)) bp->gro_func = bnxt_gro_func_5731x; }if (!BNXT_CHIP_P4_PLUS (bp))
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 9/16 bnxt_en: Add TPA ID mapping logic for 57500 chips.
In reply to Michael ChanThe new TPA feature on 57500 supports a larger number of concurrent TPAs (up to 1024) divided among the functions. We need to add some logic to map the hardware TPA ID to a software index that keeps track of each TPA in progress. A 1:1 direct mapping without translation would be too wasteful as we would have to allocate 1024 TPA structures for each RX ring on each PCI function.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 46 +++++++++++++++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 9 ++++++ 2 files changed, 53 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +44 -2
@@ -1152,6 +1152,33 @@ static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr) rxr->rx_next_cons =0xffff ; } +static u16 bnxt_alloc_agg_idx (struct bnxt_rx_ring_info *rxr,u16 agg_id) +{ +struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; +u16 idx = agg_id &MAX_TPA_P5_MASK ; + +if (test_bit (idx, map->agg_idx_bmap)) + idx =find_first_zero_bit (map->agg_idx_bmap, +BNXT_AGG_IDX_BMAP_SIZE ); +__set_bit (idx, map->agg_idx_bmap); + map->agg_id_tbl[agg_id] = idx; +return idx; +} + +static void bnxt_free_agg_idx (struct bnxt_rx_ring_info *rxr,u16 idx) +{ +struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; + +__clear_bit (idx, map->agg_idx_bmap); +} + +static u16 bnxt_lookup_agg_idx (struct bnxt_rx_ring_info *rxr,u16 agg_id) +{ +struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; + +return map->agg_id_tbl[agg_id]; +} +static void bnxt_tpa_start (struct bnxt *bp,struct bnxt_rx_ring_info *rxr,struct rx_tpa_start_cmp *tpa_start,struct rx_tpa_start_cmp_ext *tpa_start1)
@@ -1162,10 +1189,12 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,struct rx_bd *prod_bd;dma_addr_t mapping; -if (bp->flags &BNXT_FLAG_CHIP_P5 ) +if (bp->flags &BNXT_FLAG_CHIP_P5 ) { agg_id =TPA_START_AGG_ID_P5 (tpa_start); -else + agg_id =bnxt_alloc_agg_idx (rxr, agg_id); + }else { agg_id =TPA_START_AGG_ID (tpa_start); + } cons = tpa_start->rx_tpa_start_cmp_opaque; prod = rxr->rx_prod; cons_rx_buf = &rxr->rx_buf_ring[cons];
@@ -1445,6 +1474,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,if (bp->flags &BNXT_FLAG_CHIP_P5 ) { agg_id =TPA_END_AGG_ID_P5 (tpa_end); + agg_id =bnxt_lookup_agg_idx (rxr, agg_id); agg_bufs =TPA_END_AGG_BUFS_P5 (tpa_end1); tpa_info = &rxr->rx_tpa[agg_id];if (unlikely (agg_bufs != tpa_info->agg_count)) {
@@ -1454,6 +1484,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, } tpa_info->agg_count =0 ; *event |=BNXT_AGG_EVENT ; +bnxt_free_agg_idx (rxr, agg_id); idx = agg_id; gro = !!(bp->flags &BNXT_FLAG_GRO ); }else {
@@ -1560,6 +1591,7 @@ static void bnxt_tpa_agg(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,u16 agg_id =TPA_AGG_AGG_ID (rx_agg);struct bnxt_tpa_info *tpa_info; + agg_id =bnxt_lookup_agg_idx (rxr, agg_id); tpa_info = &rxr->rx_tpa[agg_id];BUG_ON (tpa_info->agg_count >=MAX_SKB_FRAGS ); tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg;
@@ -2383,6 +2415,7 @@ static void bnxt_free_rx_skbs(struct bnxt *bp) max_agg_idx = bp->rx_agg_nr_pages *RX_DESC_CNT ;for (i =0 ; i < bp->rx_nr_rings; i++) {struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; +struct bnxt_tpa_idx_map *map;int j;if (rxr->rx_tpa) {
@@ -2453,6 +2486,9 @@ static void bnxt_free_rx_skbs(struct bnxt *bp)__free_page (rxr->rx_page); rxr->rx_page =NULL ; } + map = rxr->rx_tpa_idx_map; +if (map) +memset (map->agg_idx_bmap,0 ,sizeof (map->agg_idx_bmap)); } }
@@ -2548,6 +2584,8 @@ static void bnxt_free_tpa_info(struct bnxt *bp)for (i =0 ; i < bp->rx_nr_rings; i++) {struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; +kfree (rxr->rx_tpa_idx_map); + rxr->rx_tpa_idx_map =NULL ;if (rxr->rx_tpa) {kfree (rxr->rx_tpa[0 ].agg_arr); rxr->rx_tpa[0 ].agg_arr =NULL ;
@@ -2586,6 +2624,10 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp)return -ENOMEM ;for (j =1 ; j < bp->max_tpa; j++) rxr->rx_tpa[j].agg_arr = agg + j *MAX_SKB_FRAGS ; + rxr->rx_tpa_idx_map =kzalloc (sizeof (*rxr->rx_tpa_idx_map), +GFP_KERNEL ); +if (!rxr->rx_tpa_idx_map) +return -ENOMEM ; }return 0 ; }
drivers/net/ethernet/broadcom/bnxt/bnxt.h +9 -0
@@ -555,6 +555,7 @@ struct nqe_cn {#define MAX_TPA 64#define MAX_TPA_P5 256 +#define MAX_TPA_P5_MASK (MAX_TPA_P5 - 1)#define MAX_TPA_SEGS_P5 0x3f#if (BNXT_PAGE_SHIFT ==16 )
@@ -841,6 +842,13 @@ struct bnxt_tpa_info {struct rx_agg_cmp *agg_arr; }; +#define BNXT_AGG_IDX_BMAP_SIZE (MAX_TPA_P5 / BITS_PER_LONG) + +struct bnxt_tpa_idx_map { +u16 agg_id_tbl[1024 ]; +unsigned long agg_idx_bmap[BNXT_AGG_IDX_BMAP_SIZE ]; +}; +struct bnxt_rx_ring_info {struct bnxt_napi *bnapi;u16 rx_prod;
@@ -868,6 +876,7 @@ struct bnxt_rx_ring_info {dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES ];struct bnxt_tpa_info *rx_tpa; +struct bnxt_tpa_idx_map *rx_tpa_idx_map;struct bnxt_ring_struct rx_ring_struct;struct bnxt_ring_struct rx_agg_ring_struct;
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 10/16 bnxt_en: Add hardware GRO setup function for 57500 chips.
In reply to Michael ChanAdd a more optimized hardware GRO function to setup the SKB on 57500 chips. Some workaround code is no longer needed on 57500 chips and the pseudo checksum is also calculated in hardware, so no need to do the software pseudo checksum in the driver.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +32 -1
@@ -1359,6 +1359,35 @@ static struct sk_buff *bnxt_gro_func_5731x(struct bnxt_tpa_info *tpa_info,return skb; } +static struct sk_buff *bnxt_gro_func_5750x (struct bnxt_tpa_info *tpa_info, +int payload_off,int tcp_ts, +struct sk_buff *skb) +{ +#ifdef CONFIG_INET +u16 outer_ip_off, inner_ip_off, inner_mac_off; +u32 hdr_info = tpa_info->hdr_info; +int iphdr_len, nw_off; + + inner_ip_off =BNXT_TPA_INNER_L3_OFF (hdr_info); + inner_mac_off =BNXT_TPA_INNER_L2_OFF (hdr_info); + outer_ip_off =BNXT_TPA_OUTER_L3_OFF (hdr_info); + + nw_off = inner_ip_off -ETH_HLEN ; +skb_set_network_header (skb, nw_off); + iphdr_len = (tpa_info->flags2 &RX_TPA_START_CMP_FLAGS2_IP_TYPE ) ? +sizeof (struct ipv6hdr ) :sizeof (struct iphdr ); +skb_set_transport_header (skb, nw_off + iphdr_len); + +if (inner_mac_off) {/* tunnel */ +__be16 proto = *((__be16 *)(skb->data + outer_ip_off - +ETH_HLEN -2 )); + +bnxt_gro_tunnel (skb, proto); + } +#endif +return skb; +} +#define BNXT_IPV4_HDR_SIZE (sizeof(struct iphdr) + sizeof(struct tcphdr))#define BNXT_IPV6_HDR_SIZE (sizeof(struct ipv6hdr) + sizeof(struct tcphdr))
@@ -10877,8 +10906,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)#endif if (BNXT_SUPPORTS_TPA (bp)) { bp->gro_func = bnxt_gro_func_5730x; -if (BNXT_CHIP_P4_PLUS (bp)) +if (BNXT_CHIP_P4 (bp)) bp->gro_func = bnxt_gro_func_5731x; +else if (BNXT_CHIP_P5 (bp)) + bp->gro_func = bnxt_gro_func_5750x; }if (!BNXT_CHIP_P4_PLUS (bp)) bp->flags |=BNXT_FLAG_DOUBLE_DB ;
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 11/16 bnxt_en: Refactor ethtool ring statistics logic.
In reply to Michael ChanThe current code assumes that the per ring statistics counters are fixed. In newer chips that support a newer version of TPA, the TPA counters are also changed. Refactor the code by defining these counter names in arrays so that it is easy to add a new array for a new set of counters supported by the newer chips.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 120 +++++++++++++--------- 1 file changed, 70 insertions(+), 50 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +70 -50
@@ -137,7 +137,36 @@ static int bnxt_set_coalesce(struct net_device *dev,return rc; } -#define BNXT_NUM_STATS 22 +static const char *const bnxt_ring_stats_str[] = { +"rx_ucast_packets" , +"rx_mcast_packets" , +"rx_bcast_packets" , +"rx_discards" , +"rx_drops" , +"rx_ucast_bytes" , +"rx_mcast_bytes" , +"rx_bcast_bytes" , +"tx_ucast_packets" , +"tx_mcast_packets" , +"tx_bcast_packets" , +"tx_discards" , +"tx_drops" , +"tx_ucast_bytes" , +"tx_mcast_bytes" , +"tx_bcast_bytes" , +}; + +static const char *const bnxt_ring_tpa_stats_str[] = { +"tpa_packets" , +"tpa_bytes" , +"tpa_events" , +"tpa_aborts" , +}; + +static const char *const bnxt_ring_sw_stats_str[] = { +"rx_l4_csum_errors" , +"missed_irqs" , +};#define BNXT_RX_STATS_ENTRY (counter) \ { BNXT_RX_STATS_OFFSET(counter), __stringify(counter) }
@@ -432,9 +461,20 @@ static const struct { ARRAY_SIZE(bnxt_tx_pkts_pri_arr))#define BNXT_NUM_PCIE_STATS ARRAY_SIZE(bnxt_pcie_stats_arr) +static int bnxt_get_num_ring_stats (struct bnxt *bp) +{ +int num_stats; + + num_stats =ARRAY_SIZE (bnxt_ring_stats_str) + +ARRAY_SIZE (bnxt_ring_sw_stats_str); +if (BNXT_SUPPORTS_TPA (bp)) + num_stats +=ARRAY_SIZE (bnxt_ring_tpa_stats_str); +return num_stats * bp->cp_nr_rings; +} +static int bnxt_get_num_stats (struct bnxt *bp) { -int num_stats =BNXT_NUM_STATS * bp->cp_nr_rings; +int num_stats =bnxt_get_num_ring_stats (bp); num_stats +=BNXT_NUM_SW_FUNC_STATS ;
@@ -475,10 +515,13 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, {u32 i, j =0 ;struct bnxt *bp =netdev_priv (dev); -u32 stat_fields =sizeof (struct ctx_hw_stats ) /8 ; +u32 stat_fields =ARRAY_SIZE (bnxt_ring_stats_str); + +if (BNXT_SUPPORTS_TPA (bp)) + stat_fields +=ARRAY_SIZE (bnxt_ring_tpa_stats_str);if (!bp->bnapi) { - j +=BNXT_NUM_STATS * bp->cp_nr_rings +BNXT_NUM_SW_FUNC_STATS ; + j +=bnxt_get_num_ring_stats (bp) +BNXT_NUM_SW_FUNC_STATS ; goto skip_ring_stats; }
@@ -566,56 +609,33 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,static void bnxt_get_strings (struct net_device *dev,u32 stringset,u8 *buf) {struct bnxt *bp =netdev_priv (dev); -u32 i; +u32 i, j, num_str;switch (stringset) { -/* The number of strings must match BNXT_NUM_STATS defined above. */ case ETH_SS_STATS :for (i =0 ; i < bp->cp_nr_rings; i++) { -sprintf (buf,"[%d]: rx_ucast_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_mcast_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_bcast_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_discards" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_drops" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_ucast_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_mcast_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_bcast_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_ucast_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_mcast_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_bcast_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_discards" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_drops" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_ucast_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_mcast_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tx_bcast_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tpa_packets" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tpa_bytes" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tpa_events" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: tpa_aborts" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: rx_l4_csum_errors" , i); - buf +=ETH_GSTRING_LEN ; -sprintf (buf,"[%d]: missed_irqs" , i); - buf +=ETH_GSTRING_LEN ; + num_str =ARRAY_SIZE (bnxt_ring_stats_str); +for (j =0 ; j < num_str; j++) { +sprintf (buf,"[%d]: %s" , i, + bnxt_ring_stats_str[j]); + buf +=ETH_GSTRING_LEN ; + } +if (!BNXT_SUPPORTS_TPA (bp)) + goto skip_tpa_stats; + + num_str =ARRAY_SIZE (bnxt_ring_tpa_stats_str); +for (j =0 ; j < num_str; j++) { +sprintf (buf,"[%d]: %s" , i, + bnxt_ring_tpa_stats_str[j]); + buf +=ETH_GSTRING_LEN ; + } +skip_tpa_stats: + num_str =ARRAY_SIZE (bnxt_ring_sw_stats_str); +for (j =0 ; j < num_str; j++) { +sprintf (buf,"[%d]: %s" , i, + bnxt_ring_sw_stats_str[j]); + buf +=ETH_GSTRING_LEN ; + } }for (i =0 ; i <BNXT_NUM_SW_FUNC_STATS ; i++) {strcpy (buf, bnxt_sw_func_stats[i].string);
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 12/16 bnxt_en: Allocate the larger per-ring statistics block for 57500 chips.
In reply to Michael ChanThe new TPA implemantation has additional TPA counters that extend the per-ring statistics block. Allocate the proper size accordingly.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -2
@@ -3635,7 +3635,7 @@ static void bnxt_free_ring_stats(struct bnxt *bp)if (!bp->bnapi)return ; - size =sizeof (struct ctx_hw_stats ); + size = bp->hw_ring_stats_size;for (i =0 ; i < bp->cp_nr_rings; i++) {struct bnxt_napi *bnapi = bp->bnapi[i];
@@ -3654,7 +3654,7 @@ static int bnxt_alloc_stats(struct bnxt *bp)u32 size, i;struct pci_dev *pdev = bp->pdev; - size =sizeof (struct ctx_hw_stats ); + size = bp->hw_ring_stats_size;for (i =0 ; i < bp->cp_nr_rings; i++) {struct bnxt_napi *bnapi = bp->bnapi[i];
@@ -4989,6 +4989,11 @@ static int bnxt_hwrm_vnic_qcaps(struct bnxt *bp) VNIC_QCAPS_RESP_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_CAP) bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; bp->max_tpa_v2 =le16_to_cpu (resp->max_aggs_supported); +if (bp->max_tpa_v2) + bp->hw_ring_stats_size = +sizeof (struct ctx_hw_stats_ext ); +else + bp->hw_ring_stats_size =sizeof (struct ctx_hw_stats ); }mutex_unlock (&bp->hwrm_cmd_lock);return rc;
@@ -6186,6 +6191,7 @@ static int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp)bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_STAT_CTX_ALLOC ,-1 ,-1 ); + req.stats_dma_length =cpu_to_le16 (bp->hw_ring_stats_size); req.update_period_ms =cpu_to_le32 (bp->stats_coal_ticks /1000 );mutex_lock (&bp->hwrm_cmd_lock);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1607,6 +1607,7 @@ struct bnxt {int hw_port_stats_size;u16 fw_rx_stats_ext_size;u16 fw_tx_stats_ext_size; +u16 hw_ring_stats_size;u8 pri2cos[8 ];u8 pri2cos_valid;
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 13/16 bnxt_en: Support TPA counters on 57500 chips.
In reply to Michael ChanSupport the new expanded TPA v2 counters on 57500 B0 chips for ethtool -S.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 41 +++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +31 -10
@@ -163,6 +163,14 @@ static const char * const bnxt_ring_tpa_stats_str[] = { "tpa_aborts", }; +static const char *const bnxt_ring_tpa2_stats_str[] = { +"rx_tpa_eligible_pkt" , +"rx_tpa_eligible_bytes" , +"rx_tpa_pkt" , +"rx_tpa_bytes" , +"rx_tpa_errors" , +}; +static const char *const bnxt_ring_sw_stats_str[] = {"rx_l4_csum_errors" ,"missed_irqs" ,
@@ -461,14 +469,23 @@ static const struct { ARRAY_SIZE(bnxt_tx_pkts_pri_arr))#define BNXT_NUM_PCIE_STATS ARRAY_SIZE(bnxt_pcie_stats_arr) +static int bnxt_get_num_tpa_ring_stats (struct bnxt *bp) +{ +if (BNXT_SUPPORTS_TPA (bp)) { +if (bp->max_tpa_v2) +return ARRAY_SIZE (bnxt_ring_tpa2_stats_str); +return ARRAY_SIZE (bnxt_ring_tpa_stats_str); + } +return 0 ; +} +static int bnxt_get_num_ring_stats (struct bnxt *bp) {int num_stats; num_stats =ARRAY_SIZE (bnxt_ring_stats_str) + -ARRAY_SIZE (bnxt_ring_sw_stats_str); -if (BNXT_SUPPORTS_TPA (bp)) - num_stats +=ARRAY_SIZE (bnxt_ring_tpa_stats_str); +ARRAY_SIZE (bnxt_ring_sw_stats_str) + +bnxt_get_num_tpa_ring_stats (bp);return num_stats * bp->cp_nr_rings; }
@@ -515,10 +532,8 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, {u32 i, j =0 ;struct bnxt *bp =netdev_priv (dev); -u32 stat_fields =ARRAY_SIZE (bnxt_ring_stats_str); - -if (BNXT_SUPPORTS_TPA (bp)) - stat_fields +=ARRAY_SIZE (bnxt_ring_tpa_stats_str); +u32 stat_fields =ARRAY_SIZE (bnxt_ring_stats_str) + +bnxt_get_num_tpa_ring_stats (bp);if (!bp->bnapi) { j +=bnxt_get_num_ring_stats (bp) +BNXT_NUM_SW_FUNC_STATS ;
@@ -609,6 +624,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,static void bnxt_get_strings (struct net_device *dev,u32 stringset,u8 *buf) {struct bnxt *bp =netdev_priv (dev); +static const char *const *str;u32 i, j, num_str;switch (stringset) {
@@ -623,10 +639,15 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)if (!BNXT_SUPPORTS_TPA (bp)) goto skip_tpa_stats; - num_str =ARRAY_SIZE (bnxt_ring_tpa_stats_str); +if (bp->max_tpa_v2) { + num_str =ARRAY_SIZE (bnxt_ring_tpa2_stats_str); + str = bnxt_ring_tpa2_stats_str; + }else { + num_str =ARRAY_SIZE (bnxt_ring_tpa_stats_str); + str = bnxt_ring_tpa_stats_str; + }for (j =0 ; j < num_str; j++) { -sprintf (buf,"[%d]: %s" , i, - bnxt_ring_tpa_stats_str[j]); +sprintf (buf,"[%d]: %s" , i, str[j]); buf +=ETH_GSTRING_LEN ; } skip_tpa_stats:
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 14/16 bnxt_en: Refactor bnxt_init_one() and turn on TPA support on 57500 chips.
In reply to Michael ChanWith the new TPA feature in the 57500 chips, we need to discover the feature first before setting up the netdev features. Refactor the the firmware probe and init logic more cleanly into 2 functions and and make these calls before setting up the netdev features.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 116 +++++++++++++++++------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 +- 2 files changed, 67 insertions(+), 53 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +65 -51
@@ -9896,6 +9896,68 @@ static void bnxt_init_dflt_coal(struct bnxt *bp) bp->stats_coal_ticks =BNXT_DEF_STATS_COAL_TICKS ; } +static int bnxt_fw_init_one_p1 (struct bnxt *bp) +{ +int rc; + + bp->fw_cap =0 ; + rc =bnxt_hwrm_ver_get (bp); +if (rc) +return rc; + +if (bp->fw_cap &BNXT_FW_CAP_KONG_MB_CHNL ) { + rc =bnxt_alloc_kong_hwrm_resources (bp); +if (rc) + bp->fw_cap &= ~BNXT_FW_CAP_KONG_MB_CHNL ; + } + +if ((bp->fw_cap &BNXT_FW_CAP_SHORT_CMD ) || + bp->hwrm_max_ext_req_len >BNXT_HWRM_MAX_REQ_LEN ) { + rc =bnxt_alloc_hwrm_short_cmd_req (bp); +if (rc) +return rc; + } + rc =bnxt_hwrm_func_reset (bp); +if (rc) +return -ENODEV ; + +bnxt_hwrm_fw_set_time (bp); +return 0 ; +} + +static int bnxt_fw_init_one_p2 (struct bnxt *bp) +{ +int rc; + +/* Get the MAX capabilities for this function */ + rc =bnxt_hwrm_func_qcaps (bp); +if (rc) { +netdev_err (bp->dev,"hwrm query capability failure rc: %x\n" , + rc); +return -ENODEV ; + } + + rc =bnxt_hwrm_cfa_adv_flow_mgnt_qcaps (bp); +if (rc) +netdev_warn (bp->dev,"hwrm query adv flow mgnt failure rc: %d\n" , + rc); + + rc =bnxt_hwrm_func_drv_rgtr (bp); +if (rc) +return -ENODEV ; + + rc =bnxt_hwrm_func_rgtr_async_events (bp,NULL ,0 ); +if (rc) +return -ENODEV ; + +bnxt_hwrm_func_qcfg (bp); +bnxt_hwrm_vnic_qcaps (bp); +bnxt_hwrm_port_led_qcaps (bp); +bnxt_ethtool_init (bp); +bnxt_dcb_init (bp); +return 0 ; +} +static int bnxt_init_board (struct pci_dev *pdev,struct net_device *dev) {int rc;
@@ -10851,32 +10913,18 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto init_err_pci_clean;mutex_init (&bp->hwrm_cmd_lock); - rc =bnxt_hwrm_ver_get (bp); + + rc =bnxt_fw_init_one_p1 (bp);if (rc) goto init_err_pci_clean; -if (bp->fw_cap &BNXT_FW_CAP_KONG_MB_CHNL ) { - rc =bnxt_alloc_kong_hwrm_resources (bp); -if (rc) - bp->fw_cap &= ~BNXT_FW_CAP_KONG_MB_CHNL ; - } - -if ((bp->fw_cap &BNXT_FW_CAP_SHORT_CMD ) || - bp->hwrm_max_ext_req_len >BNXT_HWRM_MAX_REQ_LEN ) { - rc =bnxt_alloc_hwrm_short_cmd_req (bp); -if (rc) - goto init_err_pci_clean; - } -if (BNXT_CHIP_P5 (bp)) bp->flags |=BNXT_FLAG_CHIP_P5 ; - rc =bnxt_hwrm_func_reset (bp); + rc =bnxt_fw_init_one_p2 (bp);if (rc) goto init_err_pci_clean; -bnxt_hwrm_fw_set_time (bp); - dev->hw_features =NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM |NETIF_F_SG |NETIF_F_TSO |NETIF_F_TSO6 | NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
@@ -10920,37 +10968,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (!BNXT_CHIP_P4_PLUS (bp)) bp->flags |=BNXT_FLAG_DOUBLE_DB ; - rc =bnxt_hwrm_func_drv_rgtr (bp); -if (rc) - goto init_err_pci_clean; - - rc =bnxt_hwrm_func_rgtr_async_events (bp,NULL ,0 ); -if (rc) - goto init_err_pci_clean; - bp->ulp_probe = bnxt_ulp_probe; - rc =bnxt_hwrm_queue_qportcfg (bp); -if (rc) { -netdev_err (bp->dev,"hwrm query qportcfg failure rc: %x\n" , - rc); - rc =-1 ; - goto init_err_pci_clean; - } -/* Get the MAX capabilities for this function */ - rc =bnxt_hwrm_func_qcaps (bp); -if (rc) { -netdev_err (bp->dev,"hwrm query capability failure rc: %x\n" , - rc); - rc =-1 ; - goto init_err_pci_clean; - } - - rc =bnxt_hwrm_cfa_adv_flow_mgnt_qcaps (bp); -if (rc) -netdev_warn (bp->dev,"hwrm query adv flow mgnt failure rc: %d\n" , - rc); - rc =bnxt_init_mac_addr (bp);if (rc) {dev_err (&pdev->dev,"Unable to initialize mac address.\n" );
@@ -10964,11 +10983,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc) goto init_err_pci_clean; } -bnxt_hwrm_func_qcfg (bp); -bnxt_hwrm_vnic_qcaps (bp); -bnxt_hwrm_port_led_qcaps (bp); -bnxt_ethtool_init (bp); -bnxt_dcb_init (bp);/* MTU range: 60 - FW defined max */ dev->min_mtu =ETH_ZLEN ;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -2
@@ -1459,8 +1459,8 @@ struct bnxt {#define BNXT_CHIP_TYPE_NITRO_A0 (bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)#define BNXT_RX_PAGE_MODE (bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)#define BNXT_SUPPORTS_TPA (bp) (!BNXT_CHIP_TYPE_NITRO_A0(bp) && \ - !(bp->flags & BNXT_FLAG_CHIP_P5) && \ - !is_kdump_kernel()) + (!((bp)->flags & BNXT_FLAG_CHIP_P5) || \ + (bp)->max_tpa_v2) && !is_kdump_kernel())/* Chip class phase 5 */ #define BNXT_CHIP_P5 (bp) \
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 15/16 bnxt_en: Support all variants of the 5750X chip family.
In reply to Michael ChanDefine the 57508, 57504, and 57502 chip IDs that are all part of the BNXT_CHIP_P5 family of chips.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +6 -2
@@ -1362,7 +1362,9 @@ struct bnxt {#define CHIP_NUM_5745X 0xd730 -#define CHIP_NUM_57500 0x1750 +#define CHIP_NUM_57508 0x1750 +#define CHIP_NUM_57504 0x1751 +#define CHIP_NUM_57502 0x1752#define CHIP_NUM_58802 0xd802#define CHIP_NUM_58804 0xd804
@@ -1464,7 +1466,9 @@ struct bnxt {/* Chip class phase 5 */ #define BNXT_CHIP_P5 (bp) \ - ((bp)->chip_num == CHIP_NUM_57500) + ((bp)->chip_num == CHIP_NUM_57508 || \ + (bp)->chip_num == CHIP_NUM_57504 || \ + (bp)->chip_num == CHIP_NUM_57502)/* Chip class phase 4.x */ #define BNXT_CHIP_P4 (bp) \
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 16/16 bnxt_en: Add PCI IDs for 57500 series NPAR devices.
In reply to Michael Chan--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +12 -0
@@ -116,6 +116,9 @@ enum board_idx {BCM57508 ,BCM57504 ,BCM57502 , +BCM57508_NPAR , +BCM57504_NPAR , +BCM57502_NPAR ,BCM58802 ,BCM58804 , BCM58808,
@@ -161,6 +164,9 @@ static const struct { [BCM57508] = { "Broadcom BCM57508 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" }, [BCM57504] = { "Broadcom BCM57504 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" }, [BCM57502] = { "Broadcom BCM57502 NetXtreme-E 10Gb/25Gb/50Gb Ethernet" }, + [BCM57508_NPAR] = { "Broadcom BCM57508 NetXtreme-E Ethernet Partition" }, + [BCM57504_NPAR] = { "Broadcom BCM57504 NetXtreme-E Ethernet Partition" }, + [BCM57502_NPAR] = { "Broadcom BCM57502 NetXtreme-E Ethernet Partition" }, [BCM58802] = { "Broadcom BCM58802 NetXtreme-S 10Gb/25Gb/40Gb/50Gb Ethernet" }, [BCM58804] = { "Broadcom BCM58804 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" }, [BCM58808] = { "Broadcom BCM58808 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
@@ -209,6 +215,12 @@ static const struct pci_device_id bnxt_pci_tbl[] = { { PCI_VDEVICE(BROADCOM, 0x1750), .driver_data = BCM57508 }, { PCI_VDEVICE(BROADCOM, 0x1751), .driver_data = BCM57504 }, { PCI_VDEVICE(BROADCOM, 0x1752), .driver_data = BCM57502 }, + { PCI_VDEVICE(BROADCOM, 0x1800), .driver_data = BCM57508_NPAR }, + { PCI_VDEVICE(BROADCOM, 0x1801), .driver_data = BCM57504_NPAR }, + { PCI_VDEVICE(BROADCOM, 0x1802), .driver_data = BCM57502_NPAR }, + { PCI_VDEVICE(BROADCOM, 0x1803), .driver_data = BCM57508_NPAR }, + { PCI_VDEVICE(BROADCOM, 0x1804), .driver_data = BCM57504_NPAR }, + { PCI_VDEVICE(BROADCOM, 0x1805), .driver_data = BCM57502_NPAR }, { PCI_VDEVICE(BROADCOM, 0xd802), .driver_data = BCM58802 }, { PCI_VDEVICE(BROADCOM, 0xd804), .driver_data = BCM58804 }, #ifdef CONFIG_BNXT_SRIOV
Signature · 1 line
2.5.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Mon, 29 Jul 2019 06:10:17 -0400
Quoted 7 lines
This patchset adds TPA v2 support on the 57500 chips. TPA v2 is different from the legacy TPA scheme on older chips and requires major refactoring and restructuring of the existing TPA logic. The main difference is that the new TPA v2 has on-the-fly aggregation buffer completions before a TPA packet is completed. The larger aggregation ID space also requires a new ID mapping logic to make it more memory efficient.
Series applied, but please explain something to me.
I thought initially while reviewing this that patch #5 makes the series non-bisectable because this only includes the logic that appends new entries to the agg array but lacks the changes to reset the agg count at TPE end time (which occurs in patch #8).
However I then realized that you haven't turned on the logic yet that can result in CMP_TYPE_RX_TPA_AGG_CMP entries in this context.
Am I right?
Michael Chan
maintainerQuoted 19 lines · David Miller
From: Michael Chan <[email protected]>
Date: Mon, 29 Jul 2019 06:10:17 -0400Quoted 7 lines
This patchset adds TPA v2 support on the 57500 chips. TPA v2 is different from the legacy TPA scheme on older chips and requires major refactoring and restructuring of the existing TPA logic. The main difference is that the new TPA v2 has on-the-fly aggregation buffer completions before a TPA packet is completed. The larger aggregation ID space also requires a new ID mapping logic to make it more memory efficient.
Series applied, but please explain something to me.
I thought initially while reviewing this that patch #5 makes the series non-bisectable because this only includes the logic that appends new entries to the agg array but lacks the changes to reset the agg count at TPE end time (which occurs in patch #8).
Quoted 4 lines
However I then realized that you haven't turned on the logic yet that can result in
CMP_TYPE_RX_TPA_AGG_CMPentries in this context.Am I right?
Yes, correct. Everything is built up incrementally and the new GRO_HW and LRO features on the new chip can only be enabled after patch #14.
Thanks.