From: Danylo Vodopianov <dvo-...@napatech.com> The Packet Description Builder module creates packet meta-data for example virtio-net headers.
Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com> --- drivers/net/ntnic/include/hw_mod_backend.h | 3 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c | 144 ++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 17 +++ 3 files changed, 164 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 2711f44083..7f1449d8ee 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -740,6 +740,9 @@ int hw_mod_pdb_alloc(struct flow_api_backend_s *be); void hw_mod_pdb_free(struct flow_api_backend_s *be); int hw_mod_pdb_reset(struct flow_api_backend_s *be); int hw_mod_pdb_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_pdb_rcp_set(struct flow_api_backend_s *be, enum hw_pdb_e field, uint32_t index, + uint32_t value); + int hw_mod_pdb_config_flush(struct flow_api_backend_s *be); struct tpe_func_s { diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c index c3facacb08..59285405ba 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c @@ -85,6 +85,150 @@ int hw_mod_pdb_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->pdb_rcp_flush(be->be_dev, &be->pdb, start_idx, count); } +static int hw_mod_pdb_rcp_mod(struct flow_api_backend_s *be, enum hw_pdb_e field, uint32_t index, + uint32_t *value, int get) +{ + if (index >= be->pdb.nb_pdb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 9: + switch (field) { + case HW_PDB_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->pdb.v9.rcp[index], (uint8_t)*value, + sizeof(struct pdb_v9_rcp_s)); + break; + + case HW_PDB_RCP_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->pdb.nb_pdb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->pdb.v9.rcp, struct pdb_v9_rcp_s, index, *value, + be->pdb.nb_pdb_rcp_categories); + break; + + case HW_PDB_RCP_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->pdb.nb_pdb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->pdb.v9.rcp, struct pdb_v9_rcp_s, index, *value); + break; + + case HW_PDB_RCP_DESCRIPTOR: + GET_SET(be->pdb.v9.rcp[index].descriptor, value); + break; + + case HW_PDB_RCP_DESC_LEN: + GET_SET(be->pdb.v9.rcp[index].desc_len, value); + break; + + case HW_PDB_RCP_TX_PORT: + GET_SET(be->pdb.v9.rcp[index].tx_port, value); + break; + + case HW_PDB_RCP_TX_IGNORE: + GET_SET(be->pdb.v9.rcp[index].tx_ignore, value); + break; + + case HW_PDB_RCP_TX_NOW: + GET_SET(be->pdb.v9.rcp[index].tx_now, value); + break; + + case HW_PDB_RCP_CRC_OVERWRITE: + GET_SET(be->pdb.v9.rcp[index].crc_overwrite, value); + break; + + case HW_PDB_RCP_ALIGN: + GET_SET(be->pdb.v9.rcp[index].align, value); + break; + + case HW_PDB_RCP_OFS0_DYN: + GET_SET(be->pdb.v9.rcp[index].ofs0_dyn, value); + break; + + case HW_PDB_RCP_OFS0_REL: + GET_SET_SIGNED(be->pdb.v9.rcp[index].ofs0_rel, value); + break; + + case HW_PDB_RCP_OFS1_DYN: + GET_SET(be->pdb.v9.rcp[index].ofs1_dyn, value); + break; + + case HW_PDB_RCP_OFS1_REL: + GET_SET_SIGNED(be->pdb.v9.rcp[index].ofs1_rel, value); + break; + + case HW_PDB_RCP_OFS2_DYN: + GET_SET(be->pdb.v9.rcp[index].ofs2_dyn, value); + break; + + case HW_PDB_RCP_OFS2_REL: + GET_SET_SIGNED(be->pdb.v9.rcp[index].ofs2_rel, value); + break; + + case HW_PDB_RCP_IP_PROT_TNL: + GET_SET(be->pdb.v9.rcp[index].ip_prot_tnl, value); + break; + + case HW_PDB_RCP_PPC_HSH: + GET_SET(be->pdb.v9.rcp[index].ppc_hsh, value); + break; + + case HW_PDB_RCP_DUPLICATE_EN: + GET_SET(be->pdb.v9.rcp[index].duplicate_en, value); + break; + + case HW_PDB_RCP_DUPLICATE_BIT: + GET_SET(be->pdb.v9.rcp[index].duplicate_bit, value); + break; + + case HW_PDB_RCP_PCAP_KEEP_FCS: + GET_SET(be->pdb.v9.rcp[index].pcap_keep_fcs, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 9 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_pdb_rcp_set(struct flow_api_backend_s *be, enum hw_pdb_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_pdb_rcp_mod(be, field, index, &value, 0); +} + int hw_mod_pdb_config_flush(struct flow_api_backend_s *be) { return be->iface->pdb_config_flush(be->be_dev, &be->pdb); diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 73fab083de..1eab579142 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -2473,6 +2473,19 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) /* SLC LR index 0 is reserved */ flow_nic_mark_resource_used(ndev, RES_SLC_LR_RCP, 0); + /* PDB setup Direct Virtio Scatter-Gather descriptor of 12 bytes for its recipe 0 + */ + if (hw_mod_pdb_rcp_set(&ndev->be, HW_PDB_RCP_DESCRIPTOR, 0, 7) < 0) + goto err_exit0; + + if (hw_mod_pdb_rcp_set(&ndev->be, HW_PDB_RCP_DESC_LEN, 0, 6) < 0) + goto err_exit0; + + if (hw_mod_pdb_rcp_flush(&ndev->be, 0, 1) < 0) + goto err_exit0; + + flow_nic_mark_resource_used(ndev, RES_PDB_RCP, 0); + /* Setup filter using matching all packets violating traffic policing parameters */ flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); @@ -2530,6 +2543,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_free_resource(ndev, RES_TPE_EXT, 0); flow_nic_free_resource(ndev, RES_TPE_RPL, 0); + hw_mod_pdb_rcp_set(&ndev->be, HW_PDB_RCP_PRESET_ALL, 0, 0); + hw_mod_pdb_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_PDB_RCP, 0); + hw_db_inline_destroy(ndev->hw_db_handle); #ifdef FLOW_DEBUG -- 2.45.0