@@ -683,6 +683,10 @@ int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int i
uint32_t value);
int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count);
+int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index,
+ uint32_t *value);
+int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index,
+ uint32_t value);
int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count);
@@ -579,3 +579,136 @@ int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int cou
}
return be->iface->flm_scrub_flush(be->be_dev, &be->flm, start_idx, count);
}
+
+static int hw_mod_flm_rcp_mod(struct flow_api_backend_s *be, enum hw_flm_e field, int index,
+ uint32_t *value, int get)
+{
+ switch (_VER_) {
+ case 25:
+ switch (field) {
+ case HW_FLM_RCP_PRESET_ALL:
+ if (get) {
+ UNSUP_FIELD_LOG;
+ return UNSUP_FIELD;
+ }
+
+ memset(&be->flm.v25.rcp[index], (uint8_t)*value,
+ sizeof(struct flm_v25_rcp_s));
+ break;
+
+ case HW_FLM_RCP_LOOKUP:
+ GET_SET(be->flm.v25.rcp[index].lookup, value);
+ break;
+
+ case HW_FLM_RCP_QW0_DYN:
+ GET_SET(be->flm.v25.rcp[index].qw0_dyn, value);
+ break;
+
+ case HW_FLM_RCP_QW0_OFS:
+ GET_SET(be->flm.v25.rcp[index].qw0_ofs, value);
+ break;
+
+ case HW_FLM_RCP_QW0_SEL:
+ GET_SET(be->flm.v25.rcp[index].qw0_sel, value);
+ break;
+
+ case HW_FLM_RCP_QW4_DYN:
+ GET_SET(be->flm.v25.rcp[index].qw4_dyn, value);
+ break;
+
+ case HW_FLM_RCP_QW4_OFS:
+ GET_SET(be->flm.v25.rcp[index].qw4_ofs, value);
+ break;
+
+ case HW_FLM_RCP_SW8_DYN:
+ GET_SET(be->flm.v25.rcp[index].sw8_dyn, value);
+ break;
+
+ case HW_FLM_RCP_SW8_OFS:
+ GET_SET(be->flm.v25.rcp[index].sw8_ofs, value);
+ break;
+
+ case HW_FLM_RCP_SW8_SEL:
+ GET_SET(be->flm.v25.rcp[index].sw8_sel, value);
+ break;
+
+ case HW_FLM_RCP_SW9_DYN:
+ GET_SET(be->flm.v25.rcp[index].sw9_dyn, value);
+ break;
+
+ case HW_FLM_RCP_SW9_OFS:
+ GET_SET(be->flm.v25.rcp[index].sw9_ofs, value);
+ break;
+
+ case HW_FLM_RCP_MASK:
+ if (get) {
+ memcpy(value, be->flm.v25.rcp[index].mask,
+ sizeof(((struct flm_v25_rcp_s *)0)->mask));
+
+ } else {
+ memcpy(be->flm.v25.rcp[index].mask, value,
+ sizeof(((struct flm_v25_rcp_s *)0)->mask));
+ }
+
+ break;
+
+ case HW_FLM_RCP_KID:
+ GET_SET(be->flm.v25.rcp[index].kid, value);
+ break;
+
+ case HW_FLM_RCP_OPN:
+ GET_SET(be->flm.v25.rcp[index].opn, value);
+ break;
+
+ case HW_FLM_RCP_IPN:
+ GET_SET(be->flm.v25.rcp[index].ipn, value);
+ break;
+
+ case HW_FLM_RCP_BYT_DYN:
+ GET_SET(be->flm.v25.rcp[index].byt_dyn, value);
+ break;
+
+ case HW_FLM_RCP_BYT_OFS:
+ GET_SET(be->flm.v25.rcp[index].byt_ofs, value);
+ break;
+
+ case HW_FLM_RCP_TXPLM:
+ GET_SET(be->flm.v25.rcp[index].txplm, value);
+ break;
+
+ case HW_FLM_RCP_AUTO_IPV4_MASK:
+ GET_SET(be->flm.v25.rcp[index].auto_ipv4_mask, value);
+ break;
+
+ default:
+ UNSUP_FIELD_LOG;
+ return UNSUP_FIELD;
+ }
+
+ break;
+
+ default:
+ UNSUP_VER_LOG;
+ return UNSUP_VER;
+ }
+
+ return 0;
+}
+
+int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index,
+ uint32_t *value)
+{
+ if (field != HW_FLM_RCP_MASK)
+ return UNSUP_VER;
+
+ return hw_mod_flm_rcp_mod(be, field, index, value, 0);
+}
+
+int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index,
+ uint32_t value)
+{
+ if (field == HW_FLM_RCP_MASK)
+ return UNSUP_VER;
+
+ return hw_mod_flm_rcp_mod(be, field, index, &value, 0);
+}
@@ -68,6 +68,9 @@ struct hw_db_inline_resource_db {
} *cat;
struct hw_db_inline_resource_db_flm_rcp {
+ struct hw_db_inline_flm_rcp_data data;
+ int ref;
+
struct hw_db_inline_resource_db_flm_ft {
struct hw_db_inline_flm_ft_data data;
struct hw_db_flm_ft idx;
@@ -96,6 +99,7 @@ struct hw_db_inline_resource_db {
uint32_t nb_cat;
uint32_t nb_flm_ft;
+ uint32_t nb_flm_rcp;
uint32_t nb_km_ft;
uint32_t nb_km_rcp;
@@ -164,6 +168,42 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle)
return -1;
}
+
+ db->nb_flm_ft = ndev->be.cat.nb_flow_types;
+ db->nb_flm_rcp = ndev->be.flm.nb_categories;
+ db->flm = calloc(db->nb_flm_rcp, sizeof(struct hw_db_inline_resource_db_flm_rcp));
+
+ if (db->flm == NULL) {
+ hw_db_inline_destroy(db);
+ return -1;
+ }
+
+ for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) {
+ db->flm[i].ft =
+ calloc(db->nb_flm_ft, sizeof(struct hw_db_inline_resource_db_flm_ft));
+
+ if (db->flm[i].ft == NULL) {
+ hw_db_inline_destroy(db);
+ return -1;
+ }
+
+ db->flm[i].match_set =
+ calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_flm_match_set));
+
+ if (db->flm[i].match_set == NULL) {
+ hw_db_inline_destroy(db);
+ return -1;
+ }
+
+ db->flm[i].cfn_map = calloc(db->nb_cat * db->nb_flm_ft,
+ sizeof(struct hw_db_inline_resource_db_flm_cfn_map));
+
+ if (db->flm[i].cfn_map == NULL) {
+ hw_db_inline_destroy(db);
+ return -1;
+ }
+ }
+
db->nb_km_ft = ndev->be.cat.nb_flow_types;
db->nb_km_rcp = ndev->be.km.nb_categories;
db->km = calloc(db->nb_km_rcp, sizeof(struct hw_db_inline_resource_db_km_rcp));
@@ -222,6 +262,16 @@ void hw_db_inline_destroy(void *db_handle)
free(db->cat);
+ if (db->flm) {
+ for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) {
+ free(db->flm[i].ft);
+ free(db->flm[i].match_set);
+ free(db->flm[i].cfn_map);
+ }
+
+ free(db->flm);
+ }
+
if (db->km) {
for (uint32_t i = 0; i < db->nb_km_rcp; ++i)
free(db->km[i].ft);
@@ -268,6 +318,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct
*(struct hw_db_tpe_ext_idx *)&idxs[i]);
break;
+ case HW_DB_IDX_TYPE_FLM_RCP:
+ hw_db_inline_flm_deref(ndev, db_handle, *(struct hw_db_flm_idx *)&idxs[i]);
+ break;
+
case HW_DB_IDX_TYPE_FLM_FT:
hw_db_inline_flm_ft_deref(ndev, db_handle,
*(struct hw_db_flm_ft *)&idxs[i]);
@@ -324,6 +378,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle,
case HW_DB_IDX_TYPE_TPE_EXT:
return &db->tpe_ext[idxs[i].ids].data;
+ case HW_DB_IDX_TYPE_FLM_RCP:
+ return &db->flm[idxs[i].id1].data;
+
case HW_DB_IDX_TYPE_FLM_FT:
return NULL; /* FTs can't be easily looked up */
@@ -481,6 +538,20 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id,
return 0;
}
+static void hw_db_inline_setup_default_flm_rcp(struct flow_nic_dev *ndev, int flm_rcp)
+{
+ uint32_t flm_mask[10];
+ memset(flm_mask, 0xff, sizeof(flm_mask));
+
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, flm_rcp, 0x0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, flm_rcp, 1);
+ hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, flm_rcp, flm_mask);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, flm_rcp, flm_rcp + 2);
+
+ hw_mod_flm_rcp_flush(&ndev->be, flm_rcp, 1);
+}
+
+
/******************************************************************************/
/* COT */
/******************************************************************************/
@@ -1268,10 +1339,17 @@ void hw_db_inline_km_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_d
void hw_db_inline_km_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx)
{
(void)ndev;
- (void)db_handle;
+ struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle;
if (idx.error)
return;
+
+ db->flm[idx.id1].ref -= 1;
+
+ if (db->flm[idx.id1].ref <= 0) {
+ memset(&db->flm[idx.id1].data, 0x0, sizeof(struct hw_db_inline_km_rcp_data));
+ db->flm[idx.id1].ref = 0;
+ }
}
/******************************************************************************/
@@ -1359,6 +1437,121 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct
km_rcp->ft[cat_offset + idx.id1].ref = 0;
}
}
+
+/******************************************************************************/
+/* FLM RCP */
+/******************************************************************************/
+
+static int hw_db_inline_flm_compare(const struct hw_db_inline_flm_rcp_data *data1,
+ const struct hw_db_inline_flm_rcp_data *data2)
+{
+ if (data1->qw0_dyn != data2->qw0_dyn || data1->qw0_ofs != data2->qw0_ofs ||
+ data1->qw4_dyn != data2->qw4_dyn || data1->qw4_ofs != data2->qw4_ofs ||
+ data1->sw8_dyn != data2->sw8_dyn || data1->sw8_ofs != data2->sw8_ofs ||
+ data1->sw9_dyn != data2->sw9_dyn || data1->sw9_ofs != data2->sw9_ofs ||
+ data1->outer_prot != data2->outer_prot || data1->inner_prot != data2->inner_prot) {
+ return 0;
+ }
+
+ for (int i = 0; i < 10; ++i)
+ if (data1->mask[i] != data2->mask[i])
+ return 0;
+
+ return 1;
+}
+
+struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle,
+ const struct hw_db_inline_flm_rcp_data *data, int group)
+{
+ struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle;
+ struct hw_db_flm_idx idx = { .raw = 0 };
+
+ idx.type = HW_DB_IDX_TYPE_FLM_RCP;
+ idx.id1 = group;
+
+ if (group == 0)
+ return idx;
+
+ if (db->flm[idx.id1].ref > 0) {
+ if (!hw_db_inline_flm_compare(data, &db->flm[idx.id1].data)) {
+ idx.error = 1;
+ return idx;
+ }
+
+ hw_db_inline_flm_ref(ndev, db, idx);
+ return idx;
+ }
+
+ db->flm[idx.id1].ref = 1;
+ memcpy(&db->flm[idx.id1].data, data, sizeof(struct hw_db_inline_flm_rcp_data));
+
+ {
+ uint32_t flm_mask[10] = {
+ data->mask[0], /* SW9 */
+ data->mask[1], /* SW8 */
+ data->mask[5], data->mask[4], data->mask[3], data->mask[2], /* QW4 */
+ data->mask[9], data->mask[8], data->mask[7], data->mask[6], /* QW0 */
+ };
+
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, idx.id1, 0x0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, idx.id1, 1);
+
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_DYN, idx.id1, data->qw0_dyn);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_OFS, idx.id1, data->qw0_ofs);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_SEL, idx.id1, 0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_DYN, idx.id1, data->qw4_dyn);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_OFS, idx.id1, data->qw4_ofs);
+
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_DYN, idx.id1, data->sw8_dyn);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_OFS, idx.id1, data->sw8_ofs);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_SEL, idx.id1, 0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_DYN, idx.id1, data->sw9_dyn);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_OFS, idx.id1, data->sw9_ofs);
+
+ hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, idx.id1, flm_mask);
+
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, idx.id1, idx.id1 + 2);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_OPN, idx.id1, data->outer_prot ? 1 : 0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_IPN, idx.id1, data->inner_prot ? 1 : 0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_DYN, idx.id1, 0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_OFS, idx.id1, -20);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_TXPLM, idx.id1, UINT32_MAX);
+
+ hw_mod_flm_rcp_flush(&ndev->be, idx.id1, 1);
+ }
+
+ return idx;
+}
+
+void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx)
+{
+ (void)ndev;
+ struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle;
+
+ if (!idx.error)
+ db->flm[idx.id1].ref += 1;
+}
+
+void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx)
+{
+ struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle;
+
+ if (idx.error)
+ return;
+
+ if (idx.id1 > 0) {
+ db->flm[idx.id1].ref -= 1;
+
+ if (db->flm[idx.id1].ref <= 0) {
+ memset(&db->flm[idx.id1].data, 0x0,
+ sizeof(struct hw_db_inline_flm_rcp_data));
+ db->flm[idx.id1].ref = 0;
+
+ hw_db_inline_setup_default_flm_rcp(ndev, idx.id1);
+ }
+ }
+}
+
/******************************************************************************/
/* FLM FT */
/******************************************************************************/
@@ -138,6 +138,7 @@ enum hw_db_idx_type {
HW_DB_IDX_TYPE_TPE,
HW_DB_IDX_TYPE_TPE_EXT,
+ HW_DB_IDX_TYPE_FLM_RCP,
HW_DB_IDX_TYPE_KM_RCP,
HW_DB_IDX_TYPE_FLM_FT,
HW_DB_IDX_TYPE_KM_FT,
@@ -165,6 +166,22 @@ struct hw_db_inline_cat_data {
uint8_t ip_prot_tunnel;
};
+struct hw_db_inline_flm_rcp_data {
+ uint64_t qw0_dyn : 5;
+ uint64_t qw0_ofs : 8;
+ uint64_t qw4_dyn : 5;
+ uint64_t qw4_ofs : 8;
+ uint64_t sw8_dyn : 5;
+ uint64_t sw8_ofs : 8;
+ uint64_t sw9_dyn : 5;
+ uint64_t sw9_ofs : 8;
+ uint64_t outer_prot : 1;
+ uint64_t inner_prot : 1;
+ uint64_t padding : 10;
+
+ uint32_t mask[10];
+};
+
struct hw_db_inline_qsl_data {
uint32_t discard : 1;
uint32_t drop : 1;
@@ -300,7 +317,10 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct
/**/
+struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle,
+ const struct hw_db_inline_flm_rcp_data *data, int group);
void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx);
+void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx);
struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle,
const struct hw_db_inline_flm_ft_data *data);
@@ -101,6 +101,11 @@ static int flm_sdram_reset(struct flow_nic_dev *ndev, int enable)
hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, 0x0);
hw_mod_flm_control_flush(&ndev->be);
+ for (uint32_t i = 1; i < ndev->be.flm.nb_categories; ++i)
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, i, 0x0);
+
+ hw_mod_flm_rcp_flush(&ndev->be, 1, ndev->be.flm.nb_categories - 1);
+
/* Wait for FLM to enter Idle state */
for (uint32_t i = 0; i < 1000000; ++i) {
uint32_t value = 0;
@@ -2657,8 +2662,8 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n
uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id,
struct rte_flow_error *error, uint32_t port_id,
uint32_t num_dest_port, uint32_t num_queues,
- uint32_t *packet_data, uint32_t *packet_mask __rte_unused,
- struct flm_flow_key_def_s *key_def __rte_unused)
+ uint32_t *packet_data, uint32_t *packet_mask,
+ struct flm_flow_key_def_s *key_def)
{
struct flow_handle *fh = calloc(1, sizeof(struct flow_handle));
@@ -2691,6 +2696,31 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n
* Flow for group 1..32
*/
+ /* Setup FLM RCP */
+ struct hw_db_inline_flm_rcp_data flm_data = {
+ .qw0_dyn = key_def->qw0_dyn,
+ .qw0_ofs = key_def->qw0_ofs,
+ .qw4_dyn = key_def->qw4_dyn,
+ .qw4_ofs = key_def->qw4_ofs,
+ .sw8_dyn = key_def->sw8_dyn,
+ .sw8_ofs = key_def->sw8_ofs,
+ .sw9_dyn = key_def->sw9_dyn,
+ .sw9_ofs = key_def->sw9_ofs,
+ .outer_prot = key_def->outer_proto,
+ .inner_prot = key_def->inner_proto,
+ };
+ memcpy(flm_data.mask, packet_mask, sizeof(uint32_t) * 10);
+ struct hw_db_flm_idx flm_idx =
+ hw_db_inline_flm_add(dev->ndev, dev->ndev->hw_db_handle, &flm_data,
+ attr->group);
+ fh->db_idxs[fh->db_idx_counter++] = flm_idx.raw;
+
+ if (flm_idx.error) {
+ NT_LOG(ERR, FILTER, "Could not reference FLM RPC resource");
+ flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error);
+ goto error_out;
+ }
+
/* Setup Actions */
uint16_t flm_rpl_ext_ptr = 0;
uint32_t flm_ft = 0;
@@ -2703,7 +2733,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n
}
/* Program flow */
- convert_fh_to_fh_flm(fh, packet_data, 2, flm_ft, flm_rpl_ext_ptr,
+ convert_fh_to_fh_flm(fh, packet_data, flm_idx.id1 + 2, flm_ft, flm_rpl_ext_ptr,
flm_scrub, attr->priority & 0x3);
flm_flow_programming(fh, NT_FLM_OP_LEARN);
@@ -3271,6 +3301,12 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev)
flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0);
flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0);
+ hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, 0, 0);
+ hw_mod_flm_rcp_flush(&ndev->be, 0, 1);
+ flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 0);
+ flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 1);
+ flow_nic_free_resource(ndev, RES_FLM_RCP, 0);
+
flow_group_handle_destroy(&ndev->group_handle);
ntnic_id_table_destroy(ndev->id_table_handle);