ULP_BITMAP_SET(params->hdr_bitmap.bits,
BNXT_ULP_FLOW_DIR_BITMASK_EGR);
+ /* Set the computed flags for no vlan tags before parsing */
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_NO_VTAG, 1);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_NO_VTAG, 1);
+
/* Parse all the items in the pattern */
while (item && item->type != RTE_FLOW_ITEM_TYPE_END) {
/* get the header information from the flow_hdr_info table */
struct ulp_rte_act_bitmap *act = ¶ms->act_bitmap;
if (ULP_BITMAP_ISSET(act->bits, BNXT_ULP_ACTION_BIT_VNIC) ||
- ULP_BITMAP_ISSET(act->bits, BNXT_ULP_ACTION_BIT_VPORT))
+ ULP_BITMAP_ISSET(act->bits, BNXT_ULP_ACTION_BIT_VPORT)) {
+ /*
+ * Reset the vnic/vport action bitmaps
+ * it is not required for match
+ */
+ ULP_BITMAP_RESET(params->act_bitmap.bits,
+ BNXT_ULP_ACTION_BIT_VNIC);
+ ULP_BITMAP_RESET(params->act_bitmap.bits,
+ BNXT_ULP_ACTION_BIT_VPORT);
return BNXT_TF_RC_SUCCESS;
+ }
/* Update the vnic details */
ulp_rte_pf_act_handler(NULL, params);
outer_vtag_num++;
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_VTAG_NUM,
outer_vtag_num);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_NO_VTAG, 0);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_ONE_VTAG, 1);
ULP_BITMAP_SET(params->hdr_bitmap.bits,
BNXT_ULP_HDR_BIT_OO_VLAN);
} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_VTAG_NUM,
outer_vtag_num);
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_TWO_VTAGS, 1);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_ONE_VTAG, 0);
ULP_BITMAP_SET(params->hdr_bitmap.bits,
BNXT_ULP_HDR_BIT_OI_VLAN);
} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
inner_vtag_num++;
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_VTAG_NUM,
inner_vtag_num);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_NO_VTAG, 0);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_ONE_VTAG, 1);
ULP_BITMAP_SET(params->hdr_bitmap.bits,
BNXT_ULP_HDR_BIT_IO_VLAN);
} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_VTAG_NUM,
inner_vtag_num);
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_TWO_VTAGS, 1);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_ONE_VTAG, 0);
ULP_BITMAP_SET(params->hdr_bitmap.bits,
BNXT_ULP_HDR_BIT_II_VLAN);
} else {
const uint8_t *tmp_buff;
buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP];
- ulp_encap_buffer_copy(buff,
- &ipv4_spec->hdr.version_ihl,
- BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS);
- buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP +
- BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS];
tmp_buff = (const uint8_t *)&ipv4_spec->hdr.packet_id;
ulp_encap_buffer_copy(buff,
tmp_buff,
BNXT_ULP_ENCAP_IPV4_ID_PROTO);
+ buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP +
+ BNXT_ULP_ENCAP_IPV4_ID_PROTO];
+ ulp_encap_buffer_copy(buff,
+ &ipv4_spec->hdr.version_ihl,
+ BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS);
}
buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP +
BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS +
struct ulp_rte_parser_params *param)
{
const struct rte_flow_action_port_id *port_id;
+ struct ulp_rte_act_prop *act;
uint32_t pid;
+ int32_t rc;
+ uint32_t ifindex;
+ uint16_t pid_s;
port_id = act_item->conf;
- if (port_id) {
- if (port_id->original) {
- BNXT_TF_DBG(ERR,
- "ParseErr:Portid Original not supported\n");
- return BNXT_TF_RC_PARSE_ERR;
- }
- /* Update the computed VNIC using port conversion */
- if (port_id->id >= RTE_MAX_ETHPORTS) {
- BNXT_TF_DBG(ERR,
- "ParseErr:Portid is not valid\n");
- return BNXT_TF_RC_PARSE_ERR;
- }
- pid = bnxt_get_vnic_id(port_id->id, BNXT_ULP_INTF_TYPE_INVALID);
+ if (!port_id) {
+ BNXT_TF_DBG(ERR,
+ "ParseErr: Invalid Argument\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+ if (port_id->original) {
+ BNXT_TF_DBG(ERR,
+ "ParseErr:Portid Original not supported\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+
+ /* Get the port db ifindex */
+ rc = ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx,
+ port_id->id,
+ &ifindex);
+ if (rc) {
+ BNXT_TF_DBG(ERR, "Invalid port id\n");
+ return BNXT_TF_RC_ERROR;
+ }
+
+ act = ¶m->act_prop;
+ if (param->dir == ULP_DIR_EGRESS) {
+ rc = ulp_port_db_vport_get(param->ulp_ctx,
+ ifindex, &pid_s);
+ if (rc)
+ return BNXT_TF_RC_ERROR;
+
+ pid = pid_s;
pid = rte_cpu_to_be_32(pid);
- memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
+ memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VPORT],
+ &pid, BNXT_ULP_ACT_PROP_SZ_VPORT);
+ } else {
+ rc = ulp_port_db_default_vnic_get(param->ulp_ctx,
+ ifindex,
+ BNXT_ULP_DRV_FUNC_VNIC,
+ &pid_s);
+ if (rc)
+ return BNXT_TF_RC_ERROR;
+
+ pid = pid_s;
+ pid = rte_cpu_to_be_32(pid);
+ memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
&pid, BNXT_ULP_ACT_PROP_SZ_VNIC);
}
- /* Update the hdr_bitmap with count */
+ /*Update the hdr_bitmap with vnic */
ULP_BITMAP_SET(param->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VNIC);
return BNXT_TF_RC_SUCCESS;
}
struct ulp_rte_parser_params *prm)
{
const struct rte_flow_action_phy_port *phy_port;
- uint32_t vport;
- struct bnxt_ulp_device_params *dparms;
- uint32_t dev_id;
+ uint32_t pid;
+ int32_t rc;
+ uint16_t pid_s;
phy_port = action_item->conf;
- if (phy_port) {
- if (phy_port->original) {
- BNXT_TF_DBG(ERR,
- "Parse Err:Port Original not supported\n");
- return BNXT_TF_RC_PARSE_ERR;
- }
- if (bnxt_ulp_cntxt_dev_id_get(prm->ulp_ctx, &dev_id)) {
- BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
- return -EINVAL;
- }
+ if (!phy_port) {
+ BNXT_TF_DBG(ERR,
+ "ParseErr: Invalid Argument\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
- dparms = bnxt_ulp_device_params_get(dev_id);
- if (!dparms) {
- BNXT_TF_DBG(DEBUG, "Failed to get device parms\n");
- return -EINVAL;
- }
+ if (phy_port->original) {
+ BNXT_TF_DBG(ERR,
+ "Parse Err:Port Original not supported\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+ if (prm->dir != ULP_DIR_EGRESS) {
+ BNXT_TF_DBG(ERR,
+ "Parse Err:Phy ports are valid only for egress\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+ /* Get the physical port details from port db */
+ rc = ulp_port_db_phy_port_vport_get(prm->ulp_ctx, phy_port->index,
+ &pid_s);
+ if (rc) {
+ BNXT_TF_DBG(DEBUG, "Failed to get port details\n");
+ return -EINVAL;
+ }
+
+ pid = pid_s;
+ pid = rte_cpu_to_be_32(pid);
+ memcpy(&prm->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VPORT],
+ &pid, BNXT_ULP_ACT_PROP_SZ_VPORT);
- if (phy_port->index > dparms->num_phy_ports) {
- BNXT_TF_DBG(ERR, "ParseErr:Phy Port is not valid\n");
+ /* update the hdr_bitmap with vport */
+ ULP_BITMAP_SET(prm->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VPORT);
+ return BNXT_TF_RC_SUCCESS;
+}
+
+/* Function to handle the parsing of RTE Flow action pop vlan. */
+int32_t
+ulp_rte_of_pop_vlan_act_handler(const struct rte_flow_action *a __rte_unused,
+ struct ulp_rte_parser_params *params)
+{
+ /* Update the act_bitmap with pop */
+ ULP_BITMAP_SET(params->act_bitmap.bits, BNXT_ULP_ACTION_BIT_POP_VLAN);
+ return BNXT_TF_RC_SUCCESS;
+}
+
+/* Function to handle the parsing of RTE Flow action push vlan. */
+int32_t
+ulp_rte_of_push_vlan_act_handler(const struct rte_flow_action *action_item,
+ struct ulp_rte_parser_params *params)
+{
+ const struct rte_flow_action_of_push_vlan *push_vlan;
+ uint16_t ethertype;
+ struct ulp_rte_act_prop *act = ¶ms->act_prop;
+
+ push_vlan = action_item->conf;
+ if (push_vlan) {
+ ethertype = push_vlan->ethertype;
+ if (tfp_cpu_to_be_16(ethertype) != RTE_ETHER_TYPE_VLAN) {
+ BNXT_TF_DBG(ERR,
+ "Parse Err: Ethertype not supported\n");
return BNXT_TF_RC_PARSE_ERR;
}
+ memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_PUSH_VLAN],
+ ðertype, BNXT_ULP_ACT_PROP_SZ_PUSH_VLAN);
+ /* Update the hdr_bitmap with push vlan */
+ ULP_BITMAP_SET(params->act_bitmap.bits,
+ BNXT_ULP_ACTION_BIT_PUSH_VLAN);
+ return BNXT_TF_RC_SUCCESS;
+ }
+ BNXT_TF_DBG(ERR, "Parse Error: Push vlan arg is invalid\n");
+ return BNXT_TF_RC_ERROR;
+}
- /* Get the vport of the physical port */
- /* TBD: shall be changed later to portdb call */
- vport = 1 << phy_port->index;
- vport = rte_cpu_to_be_32(vport);
- memcpy(&prm->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VPORT],
- &vport, BNXT_ULP_ACT_PROP_SZ_VPORT);
+/* Function to handle the parsing of RTE Flow action set vlan id. */
+int32_t
+ulp_rte_of_set_vlan_vid_act_handler(const struct rte_flow_action *action_item,
+ struct ulp_rte_parser_params *params)
+{
+ const struct rte_flow_action_of_set_vlan_vid *vlan_vid;
+ uint32_t vid;
+ struct ulp_rte_act_prop *act = ¶ms->act_prop;
+
+ vlan_vid = action_item->conf;
+ if (vlan_vid && vlan_vid->vlan_vid) {
+ vid = vlan_vid->vlan_vid;
+ memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_VLAN_VID],
+ &vid, BNXT_ULP_ACT_PROP_SZ_SET_VLAN_VID);
+ /* Update the hdr_bitmap with vlan vid */
+ ULP_BITMAP_SET(params->act_bitmap.bits,
+ BNXT_ULP_ACTION_BIT_SET_VLAN_VID);
+ return BNXT_TF_RC_SUCCESS;
}
+ BNXT_TF_DBG(ERR, "Parse Error: Vlan vid arg is invalid\n");
+ return BNXT_TF_RC_ERROR;
+}
- /* Update the hdr_bitmap with count */
- ULP_BITMAP_SET(prm->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VPORT);
- return BNXT_TF_RC_SUCCESS;
+/* Function to handle the parsing of RTE Flow action set vlan pcp. */
+int32_t
+ulp_rte_of_set_vlan_pcp_act_handler(const struct rte_flow_action *action_item,
+ struct ulp_rte_parser_params *params)
+{
+ const struct rte_flow_action_of_set_vlan_pcp *vlan_pcp;
+ uint8_t pcp;
+ struct ulp_rte_act_prop *act = ¶ms->act_prop;
+
+ vlan_pcp = action_item->conf;
+ if (vlan_pcp) {
+ pcp = vlan_pcp->vlan_pcp;
+ memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_VLAN_PCP],
+ &pcp, BNXT_ULP_ACT_PROP_SZ_SET_VLAN_PCP);
+ /* Update the hdr_bitmap with vlan vid */
+ ULP_BITMAP_SET(params->act_bitmap.bits,
+ BNXT_ULP_ACTION_BIT_SET_VLAN_PCP);
+ return BNXT_TF_RC_SUCCESS;
+ }
+ BNXT_TF_DBG(ERR, "Parse Error: Vlan pcp arg is invalid\n");
+ return BNXT_TF_RC_ERROR;
}