const struct rte_flow_item *item =
bnxt_flow_non_void_item(pattern);
int use_ntuple = 1;
+ bool has_vlan = 0;
while (item->type != RTE_FLOW_ITEM_TYPE_END) {
switch (item->type) {
+ case RTE_FLOW_ITEM_TYPE_ANY:
case RTE_FLOW_ITEM_TYPE_ETH:
- use_ntuple = 1;
+ use_ntuple = 0;
break;
case RTE_FLOW_ITEM_TYPE_VLAN:
use_ntuple = 0;
+ has_vlan = 1;
break;
case RTE_FLOW_ITEM_TYPE_IPV4:
case RTE_FLOW_ITEM_TYPE_IPV6:
case RTE_FLOW_ITEM_TYPE_UDP:
/* FALLTHROUGH */
/* need ntuple match, reset exact match */
- if (!use_ntuple) {
- PMD_DRV_LOG(ERR,
- "VLAN flow cannot use NTUPLE filter\n");
- rte_flow_error_set
- (error,
- EINVAL,
- RTE_FLOW_ERROR_TYPE_ITEM,
- item,
- "Cannot use VLAN with NTUPLE");
- return -rte_errno;
- }
use_ntuple |= 1;
break;
- case RTE_FLOW_ITEM_TYPE_ANY:
- use_ntuple = 0;
- break;
default:
PMD_DRV_LOG(DEBUG, "Unknown Flow type\n");
use_ntuple |= 0;
}
item++;
}
+
+ if (has_vlan && use_ntuple) {
+ PMD_DRV_LOG(ERR,
+ "VLAN flow cannot use NTUPLE filter\n");
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ item,
+ "Cannot use VLAN with NTUPLE");
+ return -rte_errno;
+ }
+
return use_ntuple;
}
uint8_t vni_mask[] = {0xFF, 0xFF, 0xFF};
uint8_t tni_mask[] = {0xFF, 0xFF, 0xFF};
const struct rte_flow_item_vf *vf_spec;
- uint32_t tenant_id_be = 0;
+ uint32_t tenant_id_be = 0, valid_flags = 0;
bool vni_masked = 0;
bool tni_masked = 0;
+ uint32_t en_ethertype;
+ uint8_t inner = 0;
uint32_t vf = 0;
- int use_ntuple;
uint32_t en = 0;
- uint32_t en_ethertype;
+ int use_ntuple;
int dflt_vnic;
use_ntuple = bnxt_filter_type_check(pattern, error);
}
switch (item->type) {
+ case RTE_FLOW_ITEM_TYPE_ANY:
+ inner =
+ ((const struct rte_flow_item_any *)item->spec)->num > 3;
+ if (inner)
+ PMD_DRV_LOG(DEBUG, "Parse inner header\n");
+ break;
case RTE_FLOW_ITEM_TYPE_ETH:
if (!item->spec || !item->mask)
break;
if (rte_is_broadcast_ether_addr(ð_mask->dst)) {
rte_memcpy(filter->dst_macaddr,
- ð_spec->dst, 6);
+ ð_spec->dst, RTE_ETHER_ADDR_LEN);
en |= use_ntuple ?
NTUPLE_FLTR_ALLOC_INPUT_EN_DST_MACADDR :
EM_FLOW_ALLOC_INPUT_EN_DST_MACADDR;
+ valid_flags |= inner ?
+ BNXT_FLOW_L2_INNER_DST_VALID_FLAG :
+ BNXT_FLOW_L2_DST_VALID_FLAG;
}
if (rte_is_broadcast_ether_addr(ð_mask->src)) {
rte_memcpy(filter->src_macaddr,
- ð_spec->src, 6);
+ ð_spec->src, RTE_ETHER_ADDR_LEN);
en |= use_ntuple ?
NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR :
EM_FLOW_ALLOC_INPUT_EN_SRC_MACADDR;
+ valid_flags |= inner ?
+ BNXT_FLOW_L2_INNER_SRC_VALID_FLAG :
+ BNXT_FLOW_L2_SRC_VALID_FLAG;
} /*
* else {
* PMD_DRV_LOG(ERR, "Handle this condition\n");
item++;
}
filter->enables = en;
+ filter->valid_flags = valid_flags;
return 0;
}
if (memcmp(f0->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN) == 0)
return f0;
- /* This flow needs DST MAC which is not same as port/l2 */
- PMD_DRV_LOG(DEBUG, "Create L2 filter for DST MAC\n");
+ /* Alloc new L2 filter.
+ * This flow needs MAC filter which does not match port/l2 MAC.
+ */
filter1 = bnxt_get_unused_filter(bp);
if (filter1 == NULL)
return NULL;
- filter1->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+ filter1->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE;
+ filter1->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+ if (nf->valid_flags & BNXT_FLOW_L2_SRC_VALID_FLAG ||
+ nf->valid_flags & BNXT_FLOW_L2_DST_VALID_FLAG) {
+ filter1->flags |=
+ HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
+ PMD_DRV_LOG(DEBUG, "Create Outer filter\n");
+ }
+
+ if (nf->filter_type == HWRM_CFA_L2_FILTER &&
+ (nf->valid_flags & BNXT_FLOW_L2_SRC_VALID_FLAG ||
+ nf->valid_flags & BNXT_FLOW_L2_INNER_SRC_VALID_FLAG)) {
+ PMD_DRV_LOG(DEBUG, "Create L2 filter for SRC MAC\n");
+ filter1->flags |=
+ HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_SOURCE_VALID;
+ memcpy(filter1->l2_addr, nf->src_macaddr, RTE_ETHER_ADDR_LEN);
+ } else {
+ PMD_DRV_LOG(DEBUG, "Create L2 filter for DST MAC\n");
+ memcpy(filter1->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN);
+ }
+
+ if (nf->valid_flags & BNXT_FLOW_L2_DST_VALID_FLAG ||
+ nf->valid_flags & BNXT_FLOW_L2_INNER_DST_VALID_FLAG) {
+ /* Tell the FW where to place the filter in the table. */
+ filter1->pri_hint =
+ HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_BELOW_FILTER;
+ /* This will place the filter in TCAM */
+ filter1->l2_filter_id_hint = (uint64_t)-1;
+ }
+
filter1->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
L2_FILTER_ALLOC_INPUT_EN_L2_ADDR_MASK;
- memcpy(filter1->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN);
memset(filter1->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id,
filter1);
PMD_DRV_LOG(DEBUG, "Group id is 0\n");
vnic_id = act_q->index;
}
+ PMD_DRV_LOG(DEBUG, "VNIC found\n");
vnic = &bp->vnic_info[vnic_id];
if (vnic == NULL) {
rxq = bp->rx_queues[act_q->index];
- if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) && rxq)
+ if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) && rxq &&
+ vnic->fw_vnic_id != INVALID_HW_RING_ID)
goto use_vnic;
if (!rxq ||
goto ret;
}
+ if (!(filter->valid_flags &
+ ~(BNXT_FLOW_L2_DST_VALID_FLAG |
+ BNXT_FLOW_L2_SRC_VALID_FLAG |
+ BNXT_FLOW_L2_INNER_SRC_VALID_FLAG |
+ BNXT_FLOW_L2_INNER_DST_VALID_FLAG))) {
+ PMD_DRV_LOG(DEBUG, "L2 filter created\n");
+ filter->flags = filter1->flags;
+ filter->enables = filter1->enables;
+ filter->filter_type = HWRM_CFA_L2_FILTER;
+ memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
+ filter->pri_hint = filter1->pri_hint;
+ filter->l2_filter_id_hint = filter1->l2_filter_id_hint;
+ }
filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
- PMD_DRV_LOG(DEBUG, "VNIC found\n");
break;
case RTE_FLOW_ACTION_TYPE_DROP:
vnic0 = &bp->vnic_info[0];
filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
break;
+ case RTE_FLOW_ACTION_TYPE_RSS:
+ rte_flow_error_set(error,
+ ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ act,
+ "This action is not supported right now.");
+ rc = -rte_errno;
+ goto ret;
+ //break;
default:
rte_flow_error_set(error,
HWRM_PREP(req, CFA_L2_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
req.flags = rte_cpu_to_le_32(filter->flags);
- req.flags |=
- rte_cpu_to_le_32(HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST);
enables = filter->enables |
HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
req.src_id = rte_cpu_to_le_32(filter->src_id);
if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE)
req.src_type = filter->src_type;
+ if (filter->pri_hint) {
+ req.pri_hint = filter->pri_hint;
+ req.l2_filter_id_hint =
+ rte_cpu_to_le_64(filter->l2_filter_id_hint);
+ }
req.enables = rte_cpu_to_le_32(enables);
if (dev_caps_cfg &
HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
PMD_DRV_LOG(DEBUG, "FW supports Trusted VFs\n");
+ if (dev_caps_cfg &
+ HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED) {
+ bp->flags |= BNXT_FLAG_ADV_FLOW_MGMT;
+ PMD_DRV_LOG(DEBUG, "FW supports advanced flow management\n");
+ }
error:
HWRM_UNLOCK();
return rc;
}
+
+int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp)
+{
+ struct hwrm_cfa_adv_flow_mgnt_qcaps_output *resp =
+ bp->hwrm_cmd_resp_addr;
+ struct hwrm_cfa_adv_flow_mgnt_qcaps_input req = {0};
+ uint32_t flags = 0;
+ int rc = 0;
+
+ if (!(bp->flags & BNXT_FLAG_ADV_FLOW_MGMT))
+ return rc;
+
+ if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
+ PMD_DRV_LOG(DEBUG,
+ "Not a PF or trusted VF. Command not supported\n");
+ return 0;
+ }
+
+ HWRM_PREP(req, CFA_ADV_FLOW_MGNT_QCAPS, BNXT_USE_KONG(bp));
+ rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
+
+ HWRM_CHECK_RESULT();
+ flags = rte_le_to_cpu_32(resp->flags);
+ HWRM_UNLOCK();
+
+ if (flags & HWRM_CFA_ADV_FLOW_MGNT_QCAPS_L2_HDR_SRC_FILTER_EN) {
+ bp->flow_flags |= BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN;
+ PMD_DRV_LOG(INFO, "Source L2 header filtering enabled\n");
+ }
+
+ return rc;
+}