Skip to content

Commit a7445d6

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Add support for new RX and TPA_START completion types for P7
These new completion types are supported on the new P7 chips. These new types have commonalities with the legacy types. After the refactoring, we mainly have to add new functions to handle the the new meta data formats and the RX hash information in the new types. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Link: https://lore.kernel.org/r/20231201223924.26955-11-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 39b2e62 commit a7445d6

File tree

2 files changed

+89
-23
lines changed

2 files changed

+89
-23
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,23 @@ static void bnxt_tpa_metadata(struct bnxt_tpa_info *tpa_info,
13291329
}
13301330
}
13311331

1332+
static void bnxt_tpa_metadata_v2(struct bnxt_tpa_info *tpa_info,
1333+
struct rx_tpa_start_cmp *tpa_start,
1334+
struct rx_tpa_start_cmp_ext *tpa_start1)
1335+
{
1336+
tpa_info->vlan_valid = 0;
1337+
if (TPA_START_VLAN_VALID(tpa_start)) {
1338+
u32 tpid_sel = TPA_START_VLAN_TPID_SEL(tpa_start);
1339+
u32 vlan_proto = ETH_P_8021Q;
1340+
1341+
tpa_info->vlan_valid = 1;
1342+
if (tpid_sel == RX_TPA_START_METADATA1_TPID_8021AD)
1343+
vlan_proto = ETH_P_8021AD;
1344+
tpa_info->metadata = vlan_proto << 16 |
1345+
TPA_START_METADATA0_TCI(tpa_start1);
1346+
}
1347+
}
1348+
13321349
static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
13331350
u8 cmp_type, struct rx_tpa_start_cmp *tpa_start,
13341351
struct rx_tpa_start_cmp_ext *tpa_start1)
@@ -1378,12 +1395,13 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
13781395
le32_to_cpu(tpa_start->rx_tpa_start_cmp_len_flags_type) >>
13791396
RX_TPA_START_CMP_LEN_SHIFT;
13801397
if (likely(TPA_START_HASH_VALID(tpa_start))) {
1381-
u32 hash_type = TPA_START_HASH_TYPE(tpa_start);
1382-
13831398
tpa_info->hash_type = PKT_HASH_TYPE_L4;
13841399
tpa_info->gso_type = SKB_GSO_TCPV4;
1400+
if (TPA_START_IS_IPV6(tpa_start1))
1401+
tpa_info->gso_type = SKB_GSO_TCPV6;
13851402
/* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */
1386-
if (hash_type == 3 || TPA_START_IS_IPV6(tpa_start1))
1403+
else if (cmp_type == CMP_TYPE_RX_L2_TPA_START_CMP &&
1404+
TPA_START_HASH_TYPE(tpa_start) == 3)
13871405
tpa_info->gso_type = SKB_GSO_TCPV6;
13881406
tpa_info->rss_hash =
13891407
le32_to_cpu(tpa_start->rx_tpa_start_cmp_rss_hash);
@@ -1394,7 +1412,10 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
13941412
}
13951413
tpa_info->flags2 = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_flags2);
13961414
tpa_info->hdr_info = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_hdr_info);
1397-
bnxt_tpa_metadata(tpa_info, tpa_start, tpa_start1);
1415+
if (cmp_type == CMP_TYPE_RX_L2_TPA_START_CMP)
1416+
bnxt_tpa_metadata(tpa_info, tpa_start, tpa_start1);
1417+
else
1418+
bnxt_tpa_metadata_v2(tpa_info, tpa_start, tpa_start1);
13981419
tpa_info->agg_count = 0;
13991420

14001421
rxr->rx_prod = NEXT_RX(prod);
@@ -1816,13 +1837,43 @@ static struct sk_buff *bnxt_rx_vlan(struct sk_buff *skb, u8 cmp_type,
18161837
__vlan_hwaccel_put_tag(skb, vlan_proto, vtag);
18171838
else
18181839
goto vlan_err;
1840+
} else if (cmp_type == CMP_TYPE_RX_L2_V3_CMP) {
1841+
if (RX_CMP_VLAN_VALID(rxcmp)) {
1842+
u32 tpid_sel = RX_CMP_VLAN_TPID_SEL(rxcmp);
1843+
1844+
if (tpid_sel == RX_CMP_METADATA1_TPID_8021Q)
1845+
vlan_proto = htons(ETH_P_8021Q);
1846+
else if (tpid_sel == RX_CMP_METADATA1_TPID_8021AD)
1847+
vlan_proto = htons(ETH_P_8021AD);
1848+
else
1849+
goto vlan_err;
1850+
vtag = RX_CMP_METADATA0_TCI(rxcmp1);
1851+
__vlan_hwaccel_put_tag(skb, vlan_proto, vtag);
1852+
}
18191853
}
18201854
return skb;
18211855
vlan_err:
18221856
dev_kfree_skb(skb);
18231857
return NULL;
18241858
}
18251859

1860+
static enum pkt_hash_types bnxt_rss_ext_op(struct bnxt *bp,
1861+
struct rx_cmp *rxcmp)
1862+
{
1863+
u8 ext_op;
1864+
1865+
ext_op = RX_CMP_V3_HASH_TYPE(bp, rxcmp);
1866+
switch (ext_op) {
1867+
case EXT_OP_INNER_4:
1868+
case EXT_OP_OUTER_4:
1869+
case EXT_OP_INNFL_3:
1870+
case EXT_OP_OUTFL_3:
1871+
return PKT_HASH_TYPE_L4;
1872+
default:
1873+
return PKT_HASH_TYPE_L3;
1874+
}
1875+
}
1876+
18261877
/* returns the following:
18271878
* 1 - 1 packet successfully received
18281879
* 0 - successful TPA_START, packet not completed yet
@@ -1839,7 +1890,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
18391890
struct rx_cmp *rxcmp;
18401891
struct rx_cmp_ext *rxcmp1;
18411892
u32 tmp_raw_cons = *raw_cons;
1842-
u16 cfa_code, cons, prod, cp_cons = RING_CMP(tmp_raw_cons);
1893+
u16 cons, prod, cp_cons = RING_CMP(tmp_raw_cons);
18431894
struct bnxt_sw_rx_bd *rx_buf;
18441895
unsigned int len;
18451896
u8 *data_ptr, agg_bufs, cmp_type;
@@ -1875,7 +1926,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
18751926
dma_rmb();
18761927
prod = rxr->rx_prod;
18771928

1878-
if (cmp_type == CMP_TYPE_RX_L2_TPA_START_CMP) {
1929+
if (cmp_type == CMP_TYPE_RX_L2_TPA_START_CMP ||
1930+
cmp_type == CMP_TYPE_RX_L2_TPA_START_V3_CMP) {
18791931
bnxt_tpa_start(bp, rxr, cmp_type,
18801932
(struct rx_tpa_start_cmp *)rxcmp,
18811933
(struct rx_tpa_start_cmp_ext *)rxcmp1);
@@ -2030,17 +2082,27 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
20302082
}
20312083

20322084
if (RX_CMP_HASH_VALID(rxcmp)) {
2033-
u32 hash_type = RX_CMP_HASH_TYPE(rxcmp);
2034-
enum pkt_hash_types type = PKT_HASH_TYPE_L4;
2085+
enum pkt_hash_types type;
20352086

2036-
/* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */
2037-
if (hash_type != 1 && hash_type != 3)
2038-
type = PKT_HASH_TYPE_L3;
2087+
if (cmp_type == CMP_TYPE_RX_L2_V3_CMP) {
2088+
type = bnxt_rss_ext_op(bp, rxcmp);
2089+
} else {
2090+
u32 hash_type = RX_CMP_HASH_TYPE(rxcmp);
2091+
2092+
/* RSS profiles 1 and 3 with extract code 0 for inner
2093+
* 4-tuple
2094+
*/
2095+
if (hash_type != 1 && hash_type != 3)
2096+
type = PKT_HASH_TYPE_L3;
2097+
else
2098+
type = PKT_HASH_TYPE_L4;
2099+
}
20392100
skb_set_hash(skb, le32_to_cpu(rxcmp->rx_cmp_rss_hash), type);
20402101
}
20412102

2042-
cfa_code = RX_CMP_CFA_CODE(rxcmp1);
2043-
skb->protocol = eth_type_trans(skb, bnxt_get_pkt_dev(bp, cfa_code));
2103+
if (cmp_type == CMP_TYPE_RX_L2_CMP)
2104+
dev = bnxt_get_pkt_dev(bp, RX_CMP_CFA_CODE(rxcmp1));
2105+
skb->protocol = eth_type_trans(skb, dev);
20442106

20452107
if (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) {
20462108
skb = bnxt_rx_vlan(skb, cmp_type, rxcmp, rxcmp1);
@@ -2127,7 +2189,8 @@ static int bnxt_force_rx_discard(struct bnxt *bp,
21272189
*/
21282190
dma_rmb();
21292191
cmp_type = RX_CMP_TYPE(rxcmp);
2130-
if (cmp_type == CMP_TYPE_RX_L2_CMP) {
2192+
if (cmp_type == CMP_TYPE_RX_L2_CMP ||
2193+
cmp_type == CMP_TYPE_RX_L2_V3_CMP) {
21312194
rxcmp1->rx_cmp_cfa_code_errors_v2 |=
21322195
cpu_to_le32(RX_CMPL_ERRORS_CRC_ERROR);
21332196
} else if (cmp_type == CMP_TYPE_RX_L2_TPA_END_CMP) {
@@ -2651,6 +2714,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26512714
cpr->has_more_work = 0;
26522715
cpr->had_work_done = 1;
26532716
while (1) {
2717+
u8 cmp_type;
26542718
int rc;
26552719

26562720
cons = RING_CMP(raw_cons);
@@ -2663,7 +2727,8 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26632727
* reading any further.
26642728
*/
26652729
dma_rmb();
2666-
if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) {
2730+
cmp_type = TX_CMP_TYPE(txcmp);
2731+
if (cmp_type == CMP_TYPE_TX_L2_CMP) {
26672732
u32 opaque = txcmp->tx_cmp_opaque;
26682733
struct bnxt_tx_ring_info *txr;
26692734
u16 tx_freed;
@@ -2681,7 +2746,8 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26812746
cpr->has_more_work = 1;
26822747
break;
26832748
}
2684-
} else if ((TX_CMP_TYPE(txcmp) & 0x30) == 0x10) {
2749+
} else if (cmp_type >= CMP_TYPE_RX_L2_CMP &&
2750+
cmp_type <= CMP_TYPE_RX_L2_TPA_START_V3_CMP) {
26852751
if (likely(budget))
26862752
rc = bnxt_rx_pkt(bp, cpr, &raw_cons, &event);
26872753
else
@@ -2698,12 +2764,9 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26982764
rx_pkts++;
26992765
else if (rc == -EBUSY) /* partial completion */
27002766
break;
2701-
} else if (unlikely((TX_CMP_TYPE(txcmp) ==
2702-
CMPL_BASE_TYPE_HWRM_DONE) ||
2703-
(TX_CMP_TYPE(txcmp) ==
2704-
CMPL_BASE_TYPE_HWRM_FWD_REQ) ||
2705-
(TX_CMP_TYPE(txcmp) ==
2706-
CMPL_BASE_TYPE_HWRM_ASYNC_EVENT))) {
2767+
} else if (unlikely(cmp_type == CMPL_BASE_TYPE_HWRM_DONE ||
2768+
cmp_type == CMPL_BASE_TYPE_HWRM_FWD_REQ ||
2769+
cmp_type == CMPL_BASE_TYPE_HWRM_ASYNC_EVENT)) {
27072770
bnxt_hwrm_handler(bp, txcmp);
27082771
}
27092772
raw_cons = NEXT_RAW_CMP(raw_cons);
@@ -5826,6 +5889,8 @@ static int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
58265889
bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP;
58275890
if (flags & VNIC_QCAPS_RESP_FLAGS_RSS_HASH_TYPE_DELTA_CAP)
58285891
bp->rss_cap |= BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA;
5892+
if (flags & VNIC_QCAPS_RESP_FLAGS_RSS_PROF_TCAM_MODE_ENABLED)
5893+
bp->rss_cap |= BNXT_RSS_CAP_RSS_TCAM;
58295894
bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported);
58305895
if (bp->max_tpa_v2) {
58315896
if (BNXT_CHIP_P5(bp))

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3919,7 +3919,8 @@ static int bnxt_poll_loopback(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
39193919
* reading any further.
39203920
*/
39213921
dma_rmb();
3922-
if (TX_CMP_TYPE(txcmp) == CMP_TYPE_RX_L2_CMP) {
3922+
if (TX_CMP_TYPE(txcmp) == CMP_TYPE_RX_L2_CMP ||
3923+
TX_CMP_TYPE(txcmp) == CMP_TYPE_RX_L2_V3_CMP) {
39233924
rc = bnxt_rx_loopback(bp, cpr, raw_cons, pkt_size);
39243925
raw_cons = NEXT_RAW_CMP(raw_cons);
39253926
raw_cons = NEXT_RAW_CMP(raw_cons);

0 commit comments

Comments
 (0)