#include <rte_common.h>
#include <rte_memzone.h>
+#include "otx2_common.h"
#include "otx2_ethdev.h"
/* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
#define ERR_ARRAY_SZ ((BIT(ERRCODE_ERRLEN_WIDTH)) *\
sizeof(uint32_t))
-#define LOOKUP_ARRAY_SZ (PTYPE_ARRAY_SZ + ERR_ARRAY_SZ)
+#define SA_TBL_SZ (RTE_MAX_ETHPORTS * sizeof(uint64_t))
+#define LOOKUP_ARRAY_SZ (PTYPE_ARRAY_SZ + ERR_ARRAY_SZ +\
+ SA_TBL_SZ)
const uint32_t *
otx2_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev)
{
- struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+ RTE_SET_USED(eth_dev);
static const uint32_t ptypes[] = {
RTE_PTYPE_L2_ETHER_QINQ, /* LB */
RTE_PTYPE_UNKNOWN,
};
- if (dev->rx_offload_flags & NIX_RX_OFFLOAD_PTYPE_F)
- return ptypes;
- else
- return NULL;
+ return ptypes;
+}
+
+int
+otx2_nix_ptypes_set(struct rte_eth_dev *eth_dev, uint32_t ptype_mask)
+{
+ struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+
+ if (ptype_mask) {
+ dev->rx_offload_flags |= NIX_RX_OFFLOAD_PTYPE_F;
+ dev->ptype_disable = 0;
+ } else {
+ dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_PTYPE_F;
+ dev->ptype_disable = 1;
+ }
+
+ otx2_eth_set_rx_function(eth_dev);
+
+ return 0;
}
/*
nix_create_non_tunnel_ptype_array(uint16_t *ptype)
{
uint8_t lb, lc, ld, le;
- uint16_t idx, val;
+ uint16_t val;
+ uint32_t idx;
for (idx = 0; idx < PTYPE_NON_TUNNEL_ARRAY_SZ; idx++) {
lb = idx & 0xF;
val = RTE_PTYPE_UNKNOWN;
switch (lb) {
- case NPC_LT_LB_QINQ:
+ case NPC_LT_LB_STAG_QINQ:
val |= RTE_PTYPE_L2_ETHER_QINQ;
break;
case NPC_LT_LB_CTAG:
val |= RTE_PTYPE_L4_SCTP;
break;
case NPC_LT_LD_ICMP:
+ case NPC_LT_LD_ICMP6:
val |= RTE_PTYPE_L4_ICMP;
break;
case NPC_LT_LD_IGMP:
}
}
-#define TU_SHIFT(x) ((x) >> PTYPE_WIDTH)
+#define TU_SHIFT(x) ((x) >> PTYPE_NON_TUNNEL_WIDTH)
static void
nix_create_tunnel_ptype_array(uint16_t *ptype)
{
- uint8_t le, lf, lg;
- uint16_t idx, val;
+ uint8_t lf, lg, lh;
+ uint16_t val;
+ uint32_t idx;
/* Skip non tunnel ptype array memory */
ptype = ptype + PTYPE_NON_TUNNEL_ARRAY_SZ;
for (idx = 0; idx < PTYPE_TUNNEL_ARRAY_SZ; idx++) {
- le = idx & 0xF;
- lf = (idx & 0xF0) >> 4;
- lg = (idx & 0xF00) >> 8;
+ lf = idx & 0xF;
+ lg = (idx & 0xF0) >> 4;
+ lh = (idx & 0xF00) >> 8;
val = RTE_PTYPE_UNKNOWN;
- switch (le) {
+ switch (lf) {
case NPC_LT_LF_TU_ETHER:
val |= TU_SHIFT(RTE_PTYPE_INNER_L2_ETHER);
break;
}
- switch (lf) {
+ switch (lg) {
case NPC_LT_LG_TU_IP:
val |= TU_SHIFT(RTE_PTYPE_INNER_L3_IPV4);
break;
val |= TU_SHIFT(RTE_PTYPE_INNER_L3_IPV6);
break;
}
- switch (lg) {
+ switch (lh) {
case NPC_LT_LH_TU_TCP:
val |= TU_SHIFT(RTE_PTYPE_INNER_L4_TCP);
break;
val |= TU_SHIFT(RTE_PTYPE_INNER_L4_SCTP);
break;
case NPC_LT_LH_TU_ICMP:
+ case NPC_LT_LH_TU_ICMP6:
val |= TU_SHIFT(RTE_PTYPE_INNER_L4_ICMP);
break;
}
switch (errlev) {
case NPC_ERRLEV_RE:
- /* Mark all errors as BAD checksum errors */
+ /* Mark all errors as BAD checksum errors
+ * including Outer L2 length mismatch error
+ */
if (errcode) {
val |= PKT_RX_IP_CKSUM_BAD;
val |= PKT_RX_L4_CKSUM_BAD;
val |= PKT_RX_IP_CKSUM_GOOD;
break;
case NPC_ERRLEV_NIX:
- if (errcode == NIX_RX_PERRCODE_OL4_CHK) {
- val |= PKT_RX_OUTER_L4_CKSUM_BAD;
+ if (errcode == NIX_RX_PERRCODE_OL4_CHK ||
+ errcode == NIX_RX_PERRCODE_OL4_LEN ||
+ errcode == NIX_RX_PERRCODE_OL4_PORT) {
+ val |= PKT_RX_IP_CKSUM_GOOD;
val |= PKT_RX_L4_CKSUM_BAD;
- } else if (errcode == NIX_RX_PERRCODE_IL4_CHK) {
+ val |= PKT_RX_OUTER_L4_CKSUM_BAD;
+ } else if (errcode == NIX_RX_PERRCODE_IL4_CHK ||
+ errcode == NIX_RX_PERRCODE_IL4_LEN ||
+ errcode == NIX_RX_PERRCODE_IL4_PORT) {
+ val |= PKT_RX_IP_CKSUM_GOOD;
val |= PKT_RX_L4_CKSUM_BAD;
+ } else if (errcode == NIX_RX_PERRCODE_IL3_LEN ||
+ errcode == NIX_RX_PERRCODE_OL3_LEN) {
+ val |= PKT_RX_IP_CKSUM_BAD;
} else {
val |= PKT_RX_IP_CKSUM_GOOD;
val |= PKT_RX_L4_CKSUM_GOOD;
}
break;
}
-
ol_flags[idx] = val;
}
}
void *
otx2_nix_fastpath_lookup_mem_get(void)
{
- const char name[] = "otx2_nix_fastpath_lookup_mem";
+ const char name[] = OTX2_NIX_FASTPATH_LOOKUP_MEM;
const struct rte_memzone *mz;
void *mem;
+ /* SA_TBL starts after PTYPE_ARRAY & ERR_ARRAY */
+ RTE_BUILD_BUG_ON(OTX2_NIX_SA_TBL_START != (PTYPE_ARRAY_SZ +
+ ERR_ARRAY_SZ));
+
mz = rte_memzone_lookup(name);
if (mz != NULL)
return mz->addr;