*/
#include "bnxt.h"
-#include "ulp_template_db.h"
+#include "ulp_template_db_enum.h"
#include "ulp_template_struct.h"
#include "bnxt_tf_common.h"
#include "ulp_rte_parser.h"
#include "ulp_utils.h"
#include "tfp.h"
-
-/* Inline Func to read integer that is stored in big endian format */
-static inline void ulp_util_field_int_read(uint8_t *buffer,
- uint32_t *val)
-{
- uint32_t temp_val;
-
- memcpy(&temp_val, buffer, sizeof(uint32_t));
- *val = rte_be_to_cpu_32(temp_val);
-}
-
-/* Inline Func to write integer that is stored in big endian format */
-static inline void ulp_util_field_int_write(uint8_t *buffer,
- uint32_t val)
-{
- uint32_t temp_val = rte_cpu_to_be_32(val);
-
- memcpy(buffer, &temp_val, sizeof(uint32_t));
-}
+#include "ulp_port_db.h"
/* Utility function to skip the void items. */
static inline int32_t
return 0;
}
+/* Utility function to update the field_bitmap */
+static void
+ulp_rte_parser_field_bitmap_update(struct ulp_rte_parser_params *params,
+ uint32_t idx)
+{
+ struct ulp_rte_hdr_field *field;
+
+ field = ¶ms->hdr_field[idx];
+ if (ulp_bitmap_notzero(field->mask, field->size)) {
+ ULP_INDEX_BITMAP_SET(params->fld_bitmap.bits, idx);
+ /* Not exact match */
+ if (!ulp_bitmap_is_ones(field->mask, field->size))
+ ULP_BITMAP_SET(params->fld_bitmap.bits,
+ BNXT_ULP_MATCH_TYPE_BITMASK_WM);
+ } else {
+ ULP_INDEX_BITMAP_RESET(params->fld_bitmap.bits, idx);
+ }
+}
+
/* Utility function to copy field spec items */
static struct ulp_rte_hdr_field *
ulp_rte_parser_fld_copy(struct ulp_rte_hdr_field *field,
const void *buffer,
uint32_t size)
{
- struct ulp_rte_hdr_field *field = ¶ms->hdr_field[*idx];
+ struct ulp_rte_hdr_field *field = ¶ms->hdr_field[*idx];
memcpy(field->mask, buffer, size);
+ ulp_rte_parser_field_bitmap_update(params, *idx);
*idx = *idx + 1;
}
const struct rte_flow_item *item = pattern;
struct bnxt_ulp_rte_hdr_info *hdr_info;
- params->field_idx = BNXT_ULP_HDR_FIELD_LAST;
+ params->field_idx = BNXT_ULP_PROTO_HDR_SVIF_NUM;
+ if (params->dir == ULP_DIR_EGRESS)
+ 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 */
const struct rte_flow_action *action_item = actions;
struct bnxt_ulp_rte_act_info *hdr_info;
+ if (params->dir == ULP_DIR_EGRESS)
+ ULP_BITMAP_SET(params->act_bitmap.bits,
+ BNXT_ULP_FLOW_DIR_BITMASK_EGR);
+
/* Parse all the items in the pattern */
while (action_item && action_item->type != RTE_FLOW_ACTION_TYPE_END) {
/* get the header information from the flow_hdr_info table */
}
action_item++;
}
+ /* update the implied VNIC */
+ ulp_rte_parser_vnic_process(params);
return BNXT_TF_RC_SUCCESS;
}
{
uint16_t port_id = svif;
uint32_t dir = 0;
-
- if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF)) {
+ struct ulp_rte_hdr_field *hdr_field;
+ enum bnxt_ulp_svif_type svif_type;
+ enum bnxt_ulp_intf_type if_type;
+ uint32_t ifindex;
+ int32_t rc;
+
+ if (ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_SVIF_FLAG) !=
+ BNXT_ULP_INVALID_SVIF_VAL) {
BNXT_TF_DBG(ERR,
- "SVIF already set,"
- " multiple sources not supported\n");
+ "SVIF already set,multiple source not support'd\n");
return BNXT_TF_RC_ERROR;
}
- /* Update the hdr_bitmap with BNXT_ULP_HDR_PROTO_SVIF. */
- ULP_BITMAP_SET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF);
-
if (proto == RTE_FLOW_ITEM_TYPE_PORT_ID) {
- /* perform the conversion from dpdk port to svif */
- dir = params->dir;
- if (dir == ULP_DIR_EGRESS)
- svif = bnxt_get_svif(port_id, true);
- else
- svif = bnxt_get_svif(port_id, false);
- }
+ dir = ULP_COMP_FLD_IDX_RD(params,
+ BNXT_ULP_CF_IDX_DIRECTION);
+ /* perform the conversion from dpdk port to bnxt svif */
+ rc = ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, port_id,
+ &ifindex);
+ if (rc) {
+ BNXT_TF_DBG(ERR,
+ "Invalid port id\n");
+ return BNXT_TF_RC_ERROR;
+ }
- memcpy(params->hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec,
- &svif, sizeof(svif));
- memcpy(params->hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask,
- &mask, sizeof(mask));
- params->hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif);
+ if (dir == ULP_DIR_INGRESS) {
+ svif_type = BNXT_ULP_PHY_PORT_SVIF;
+ } else {
+ if_type = bnxt_get_interface_type(port_id);
+ if (if_type == BNXT_ULP_INTF_TYPE_VF_REP)
+ svif_type = BNXT_ULP_VF_FUNC_SVIF;
+ else
+ svif_type = BNXT_ULP_DRV_FUNC_SVIF;
+ }
+ ulp_port_db_svif_get(params->ulp_ctx, ifindex, svif_type,
+ &svif);
+ svif = rte_cpu_to_be_16(svif);
+ }
+ hdr_field = ¶ms->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];
+ memcpy(hdr_field->spec, &svif, sizeof(svif));
+ memcpy(hdr_field->mask, &mask, sizeof(mask));
+ hdr_field->size = sizeof(svif);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_SVIF_FLAG,
+ rte_be_to_cpu_16(svif));
return BNXT_TF_RC_SUCCESS;
}
-/* Function to handle the parsing of the RTE port id
- */
+/* Function to handle the parsing of the RTE port id */
int32_t
ulp_rte_parser_svif_process(struct ulp_rte_parser_params *params)
{
uint16_t port_id = 0;
- uint8_t *buffer;
uint16_t svif_mask = 0xFFFF;
- if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF))
+ if (ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_SVIF_FLAG) !=
+ BNXT_ULP_INVALID_SVIF_VAL)
return BNXT_TF_RC_SUCCESS;
- /* SVIF not set. So get the port id and direction */
- buffer = params->hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
- memcpy(&port_id, buffer, sizeof(port_id));
- memset(buffer, 0, RTE_PARSER_FLOW_HDR_FIELD_SIZE);
+ /* SVIF not set. So get the port id */
+ port_id = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF);
- return ulp_rte_parser_svif_set(params,
- RTE_FLOW_ITEM_TYPE_PORT_ID,
+ /* Update the SVIF details */
+ return ulp_rte_parser_svif_set(params, RTE_FLOW_ITEM_TYPE_PORT_ID,
port_id, svif_mask);
}
+/* Function to handle the implicit VNIC RTE port id */
+int32_t
+ulp_rte_parser_vnic_process(struct ulp_rte_parser_params *params)
+{
+ 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)) {
+ /*
+ * 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);
+ /* Reset the hdr_bitmap with vnic bit */
+ ULP_BITMAP_RESET(params->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VNIC);
+
+ return BNXT_TF_RC_SUCCESS;
+}
+
/* Function to handle the parsing of RTE Flow item PF Header. */
int32_t
ulp_rte_pf_hdr_handler(const struct rte_flow_item *item,
struct ulp_rte_parser_params *params)
{
uint16_t port_id = 0;
- uint8_t *buffer;
uint16_t svif_mask = 0xFFFF;
- buffer = params->hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
- memcpy(&port_id, buffer, sizeof(port_id));
- memset(buffer, 0, RTE_PARSER_FLOW_HDR_FIELD_SIZE);
+ /* Get the port id */
+ port_id = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF);
+ /* Update the SVIF details */
return ulp_rte_parser_svif_set(params,
item->type,
port_id, svif_mask);
* Copy the rte_flow_item for Port into hdr_field using port id
* header fields.
*/
- if (port_spec)
+ if (port_spec) {
svif = (uint16_t)port_spec->id;
+ if (svif >= RTE_MAX_ETHPORTS) {
+ BNXT_TF_DBG(ERR, "ParseErr:Portid is not valid\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+ }
if (port_mask)
mask = (uint16_t)port_mask->id;
const struct rte_flow_item_phy_port *port_spec = item->spec;
const struct rte_flow_item_phy_port *port_mask = item->mask;
uint32_t svif = 0, mask = 0;
+ struct bnxt_ulp_device_params *dparms;
+ uint32_t dev_id;
/* Copy the rte_flow_item for phy port into hdr_field */
if (port_spec)
if (port_mask)
mask = port_mask->index;
+ if (bnxt_ulp_cntxt_dev_id_get(params->ulp_ctx, &dev_id)) {
+ BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
+ return -EINVAL;
+ }
+
+ dparms = bnxt_ulp_device_params_get(dev_id);
+ if (!dparms) {
+ BNXT_TF_DBG(DEBUG, "Failed to get device parms\n");
+ return -EINVAL;
+ }
+
+ if (svif > dparms->num_phy_ports) {
+ BNXT_TF_DBG(ERR, "ParseErr:Phy Port is not valid\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+
/* Update the SVIF details */
return ulp_rte_parser_svif_set(params, item->type, svif, mask);
}
const struct rte_flow_item_vlan *vlan_spec = item->spec;
const struct rte_flow_item_vlan *vlan_mask = item->mask;
struct ulp_rte_hdr_field *field;
- struct ulp_rte_hdr_bitmap *hdr_bitmap;
+ struct ulp_rte_hdr_bitmap *hdr_bit;
uint32_t idx = params->vlan_idx;
uint16_t vlan_tag, priority;
- uint32_t outer_vtag_num = 0, inner_vtag_num = 0;
- uint8_t *outer_tag_buff;
- uint8_t *inner_tag_buff;
-
- outer_tag_buff = params->hdr_field[BNXT_ULP_HDR_FIELD_O_VTAG_NUM].spec;
- inner_tag_buff = params->hdr_field[BNXT_ULP_HDR_FIELD_I_VTAG_NUM].spec;
+ uint32_t outer_vtag_num;
+ uint32_t inner_vtag_num;
/*
* Copy the rte_flow_item for vlan into hdr_field using Vlan
params->vlan_idx += BNXT_ULP_PROTO_HDR_S_VLAN_NUM;
/* Get the outer tag and inner tag counts */
- ulp_util_field_int_read(outer_tag_buff, &outer_vtag_num);
- ulp_util_field_int_read(inner_tag_buff, &inner_vtag_num);
+ outer_vtag_num = ULP_COMP_FLD_IDX_RD(params,
+ BNXT_ULP_CF_IDX_O_VTAG_NUM);
+ inner_vtag_num = ULP_COMP_FLD_IDX_RD(params,
+ BNXT_ULP_CF_IDX_I_VTAG_NUM);
/* Update the hdr_bitmap of the vlans */
- hdr_bitmap = ¶ms->hdr_bitmap;
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
- !ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_OO_VLAN)) {
- /* Set the outer vlan bit and update the vlan tag num */
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_OO_VLAN);
+ hdr_bit = ¶ms->hdr_bitmap;
+ if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
+ !ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
+ !outer_vtag_num) {
+ /* Update the vlan tag num */
outer_vtag_num++;
- ulp_util_field_int_write(outer_tag_buff, outer_vtag_num);
- params->hdr_field[BNXT_ULP_HDR_FIELD_O_VTAG_NUM].size =
- sizeof(uint32_t);
- } else if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_OO_VLAN) &&
- !ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_OI_VLAN)) {
- /* Set the outer vlan bit and update the vlan tag num */
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_OI_VLAN);
+ 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_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
+ outer_vtag_num == 1) {
+ /* update the vlan tag num */
outer_vtag_num++;
- ulp_util_field_int_write(outer_tag_buff, outer_vtag_num);
- params->hdr_field[BNXT_ULP_HDR_FIELD_O_VTAG_NUM].size =
- sizeof(uint32_t);
- } else if (ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_O_ETH) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_OO_VLAN) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_OI_VLAN) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_I_ETH) &&
- !ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_IO_VLAN)) {
- /* Set the inner vlan bit and update the vlan tag num */
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_IO_VLAN);
+ 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) &&
+ ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
+ !inner_vtag_num) {
+ /* update the vlan tag num */
inner_vtag_num++;
- ulp_util_field_int_write(inner_tag_buff, inner_vtag_num);
- params->hdr_field[BNXT_ULP_HDR_FIELD_I_VTAG_NUM].size =
- sizeof(uint32_t);
- } else if (ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_O_ETH) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_OO_VLAN) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_OI_VLAN) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_I_ETH) &&
- ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_IO_VLAN) &&
- !ULP_BITMAP_ISSET(hdr_bitmap->bits,
- BNXT_ULP_HDR_BIT_II_VLAN)) {
- /* Set the inner vlan bit and update the vlan tag num */
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_II_VLAN);
+ 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_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
+ inner_vtag_num == 1) {
+ /* update the vlan tag num */
inner_vtag_num++;
- ulp_util_field_int_write(inner_tag_buff, inner_vtag_num);
- params->hdr_field[BNXT_ULP_HDR_FIELD_I_VTAG_NUM].size =
- sizeof(uint32_t);
+ 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 {
BNXT_TF_DBG(ERR, "Error Parsing:Vlan hdr found withtout eth\n");
return BNXT_TF_RC_ERROR;
struct ulp_rte_hdr_bitmap *hdr_bitmap = ¶ms->hdr_bitmap;
uint32_t idx = params->field_idx;
uint32_t size;
+ uint32_t inner_l3, outer_l3;
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L3)) {
+ inner_l3 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_I_L3);
+ if (inner_l3) {
BNXT_TF_DBG(ERR, "Parse Error:Third L3 header not supported\n");
return BNXT_TF_RC_ERROR;
}
params->field_idx += BNXT_ULP_PROTO_HDR_IPV4_NUM;
/* Set the ipv4 header bitmap and computed l3 header bitmaps */
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L3) ||
+ outer_l3 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_O_L3);
+ if (outer_l3 ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4) ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV6)) {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_IPV4);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L3);
+ inner_l3++;
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L3, inner_l3);
} else {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L3);
+ outer_l3++;
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L3, outer_l3);
}
return BNXT_TF_RC_SUCCESS;
}
struct ulp_rte_hdr_bitmap *hdr_bitmap = ¶ms->hdr_bitmap;
uint32_t idx = params->field_idx;
uint32_t size;
+ uint32_t inner_l3, outer_l3;
+ uint32_t vtcf, vtcf_mask;
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L3)) {
+ inner_l3 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_I_L3);
+ if (inner_l3) {
BNXT_TF_DBG(ERR, "Parse Error: 3'rd L3 header not supported\n");
return BNXT_TF_RC_ERROR;
}
/*
- * Copy the rte_flow_item for ipv4 into hdr_field using ipv4
+ * Copy the rte_flow_item for ipv6 into hdr_field using ipv6
* header fields
*/
if (ipv6_spec) {
size = sizeof(ipv6_spec->hdr.vtc_flow);
+
+ vtcf = BNXT_ULP_GET_IPV6_VER(ipv6_spec->hdr.vtc_flow);
field = ulp_rte_parser_fld_copy(¶ms->hdr_field[idx],
- &ipv6_spec->hdr.vtc_flow,
+ &vtcf,
+ size);
+
+ vtcf = BNXT_ULP_GET_IPV6_TC(ipv6_spec->hdr.vtc_flow);
+ field = ulp_rte_parser_fld_copy(field,
+ &vtcf,
size);
+
+ vtcf = BNXT_ULP_GET_IPV6_FLOWLABEL(ipv6_spec->hdr.vtc_flow);
+ field = ulp_rte_parser_fld_copy(field,
+ &vtcf,
+ size);
+
size = sizeof(ipv6_spec->hdr.payload_len);
field = ulp_rte_parser_fld_copy(field,
&ipv6_spec->hdr.payload_len,
size);
}
if (ipv6_mask) {
+ size = sizeof(ipv6_mask->hdr.vtc_flow);
+
+ vtcf_mask = BNXT_ULP_GET_IPV6_VER(ipv6_mask->hdr.vtc_flow);
ulp_rte_prsr_mask_copy(params, &idx,
- &ipv6_mask->hdr.vtc_flow,
- sizeof(ipv6_mask->hdr.vtc_flow));
+ &vtcf_mask,
+ size);
+
+ vtcf_mask = BNXT_ULP_GET_IPV6_TC(ipv6_mask->hdr.vtc_flow);
+ ulp_rte_prsr_mask_copy(params, &idx,
+ &vtcf_mask,
+ size);
+
+ vtcf_mask =
+ BNXT_ULP_GET_IPV6_FLOWLABEL(ipv6_mask->hdr.vtc_flow);
+ ulp_rte_prsr_mask_copy(params, &idx,
+ &vtcf_mask,
+ size);
+
ulp_rte_prsr_mask_copy(params, &idx,
&ipv6_mask->hdr.payload_len,
sizeof(ipv6_mask->hdr.payload_len));
params->field_idx += BNXT_ULP_PROTO_HDR_IPV6_NUM;
/* Set the ipv6 header bitmap and computed l3 header bitmaps */
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L3) ||
+ outer_l3 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_O_L3);
+ if (outer_l3 ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4) ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV6)) {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_IPV6);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L3);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L3, 1);
} else {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV6);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L3);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L3, 1);
}
return BNXT_TF_RC_SUCCESS;
}
struct ulp_rte_hdr_bitmap *hdr_bitmap = ¶ms->hdr_bitmap;
uint32_t idx = params->field_idx;
uint32_t size;
+ uint32_t inner_l4, outer_l4;
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L4)) {
+ inner_l4 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_I_L4);
+ if (inner_l4) {
BNXT_TF_DBG(ERR, "Parse Err:Third L4 header not supported\n");
return BNXT_TF_RC_ERROR;
}
params->field_idx += BNXT_ULP_PROTO_HDR_UDP_NUM;
/* Set the udp header bitmap and computed l4 header bitmaps */
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L4) ||
+ outer_l4 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_O_L4);
+ if (outer_l4 ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP) ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_TCP)) {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_UDP);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L4);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L4, 1);
} else {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L4);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L4, 1);
}
return BNXT_TF_RC_SUCCESS;
}
struct ulp_rte_hdr_bitmap *hdr_bitmap = ¶ms->hdr_bitmap;
uint32_t idx = params->field_idx;
uint32_t size;
+ uint32_t inner_l4, outer_l4;
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L4)) {
+ inner_l4 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_I_L4);
+ if (inner_l4) {
BNXT_TF_DBG(ERR, "Parse Error:Third L4 header not supported\n");
return BNXT_TF_RC_ERROR;
}
params->field_idx += BNXT_ULP_PROTO_HDR_TCP_NUM;
/* Set the udp header bitmap and computed l4 header bitmaps */
- if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L4) ||
+ outer_l4 = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_O_L4);
+ if (outer_l4 ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP) ||
ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_TCP)) {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_TCP);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_L4);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L4, 1);
} else {
ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_TCP);
- ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_L4);
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L4, 1);
}
return BNXT_TF_RC_SUCCESS;
}
eth_spec->dst.addr_bytes,
BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_DMAC);
+ buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC];
+ ulp_encap_buffer_copy(buff,
+ eth_spec->src.addr_bytes,
+ BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_SMAC);
+
/* Goto the next item */
if (!ulp_rte_item_skip_void(&item, 1))
return BNXT_TF_RC_ERROR;
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 +
(const uint8_t *)&ipv4_spec->hdr.dst_addr,
BNXT_ULP_ENCAP_IPV4_DEST_IP);
+ buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC];
+ ulp_encap_buffer_copy(buff,
+ (const uint8_t *)&ipv4_spec->hdr.src_addr,
+ BNXT_ULP_ACT_PROP_SZ_ENCAP_IP_SRC);
+
/* Update the ip size details */
ip_size = tfp_cpu_to_be_32(ip_size);
memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SZ],
memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE],
&ip_type, sizeof(uint32_t));
+ /* update the computed field to notify it is ipv4 header */
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG,
+ 1);
+
if (!ulp_rte_item_skip_void(&item, 1))
return BNXT_TF_RC_ERROR;
} else if (item->type == RTE_FLOW_ITEM_TYPE_IPV6) {
memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE],
&ip_type, sizeof(uint32_t));
+ /* update the computed field to notify it is ipv6 header */
+ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG,
+ 1);
+
if (!ulp_rte_item_skip_void(&item, 1))
return BNXT_TF_RC_ERROR;
} else {
/* Function to handle the parsing of RTE Flow action PF. */
int32_t
ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused,
- struct ulp_rte_parser_params *param)
+ struct ulp_rte_parser_params *params)
{
- uint8_t *svif_buf;
- uint8_t *vnic_buffer;
uint32_t svif;
/* Update the hdr_bitmap with vnic bit */
- ULP_BITMAP_SET(param->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VNIC);
+ ULP_BITMAP_SET(params->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VNIC);
/* copy the PF of the current device into VNIC Property */
- svif_buf = ¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC];
- ulp_util_field_int_read(svif_buf, &svif);
- svif = (uint32_t)bnxt_get_vnic_id(svif);
- svif = htonl(svif);
- vnic_buffer = ¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC];
- ulp_util_field_int_write(vnic_buffer, svif);
+ svif = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF);
+ svif = bnxt_get_vnic_id(svif, BNXT_ULP_INTF_TYPE_INVALID);
+ svif = rte_cpu_to_be_32(svif);
+ memcpy(¶ms->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
+ &svif, BNXT_ULP_ACT_PROP_SZ_VNIC);
return BNXT_TF_RC_SUCCESS;
}
struct ulp_rte_parser_params *param)
{
const struct rte_flow_action_vf *vf_action;
+ uint32_t pid;
vf_action = action_item->conf;
if (vf_action) {
return BNXT_TF_RC_PARSE_ERR;
}
/* TBD: Update the computed VNIC using VF conversion */
+ pid = bnxt_get_vnic_id(vf_action->id,
+ BNXT_ULP_INTF_TYPE_INVALID);
+ pid = rte_cpu_to_be_32(pid);
memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
- &vf_action->id,
- BNXT_ULP_ACT_PROP_SZ_VNIC);
+ &pid, BNXT_ULP_ACT_PROP_SZ_VNIC);
}
/* Update the hdr_bitmap with count */
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;
- }
- /* TBD: Update the computed VNIC using port conversion */
- memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
- &port_id->id,
- BNXT_ULP_ACT_PROP_SZ_VNIC);
+ 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;
}
- /* Update the hdr_bitmap with count */
+ /* 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(&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 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 pid;
+ int32_t rc;
+ uint16_t pid_s;
phy_port = action_item->conf;
- if (phy_port) {
- if (phy_port->original) {
+ if (!phy_port) {
+ BNXT_TF_DBG(ERR,
+ "ParseErr: Invalid Argument\n");
+ return BNXT_TF_RC_PARSE_ERR;
+ }
+
+ 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);
+
+ /* 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:Port Original not supported\n");
+ "Parse Err: Ethertype not supported\n");
return BNXT_TF_RC_PARSE_ERR;
}
- memcpy(&prm->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VPORT],
- &phy_port->index,
- BNXT_ULP_ACT_PROP_SZ_VPORT);
+ 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;
+}
- /* 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 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;
+}
+
+/* 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;
}