Skip to content

Commit

Permalink
app: ovs-offload: update ready meaage
Browse files Browse the repository at this point in the history
Presently, as part of READY message, sending both host and mac
port's hw_func. which is not required, sending MAC port's hw_func
is enough.

Hence, appropriate changes are made to send only MAC port's hw_func.

Signed-off-by: Hanumanth Pothula <hpothula@marvell.com>
Change-Id: I3473b0b89d0b5324cad54022972fc4eb1eff3b7f
Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpu-offload/+/128170
Tested-by: sa_ip-toolkits-Jenkins <sa_ip-toolkits-jenkins@marvell.com>
Reviewed-by: Harman Kalra <hkalra@marvell.com>
  • Loading branch information
hpothula-git authored and jerinjacobk committed May 27, 2024
1 parent f9d7dce commit 51fc63f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 46 deletions.
15 changes: 9 additions & 6 deletions app/ovs-offload/control/ood_msg_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,16 @@ populate_ready_msg(struct ood_main_cfg_data *ood_main_cfg, void *buffer, uint32_
uint32_t len;

eth_prm = ood_main_cfg->eth_prm;
total_sz = sz + (eth_prm->nb_ports * sizeof(uint16_t));
total_sz = sz + ((eth_prm->nb_ports / 2) * sizeof(uint16_t));
populate_command(buffer, length, OOD_MSG_READY, total_sz);

len = *length;
/* Populate ready message data */
rdata = rte_zmalloc("Ready", total_sz, 0);
rdata->val = 1;
rdata->nb_ports = eth_prm->nb_ports;
rte_memcpy(rdata->data, eth_prm->hw_func, eth_prm->nb_ports * sizeof(uint16_t));
rdata->nb_ports = eth_prm->nb_ports / 2;
for (int i = 0; i < rdata->nb_ports; i++)
rdata->data[i] = eth_prm->host_mac_map[i].mac_port.hw_func;

rte_memcpy(RTE_PTR_ADD(buffer, len), rdata, total_sz);

Expand Down Expand Up @@ -281,16 +282,18 @@ populate_exit_msg(struct ood_main_cfg_data *ood_main_cfg, void *buffer, uint32_t
uint32_t len;

eth_prm = ood_main_cfg->eth_prm;
total_sz = sz + (eth_prm->nb_ports * sizeof(uint16_t));
total_sz = sz + ((eth_prm->nb_ports / 2) * sizeof(uint16_t));
populate_command(buffer, length, OOD_MSG_EXIT, total_sz);

len = *length;

/* Populate exit message data */
edata = rte_zmalloc("Exit", total_sz, 0);
edata->val = 1;
edata->nb_ports = eth_prm->nb_ports;
rte_memcpy(edata->data, eth_prm->hw_func, eth_prm->nb_ports * sizeof(uint16_t));
edata->nb_ports = eth_prm->nb_ports / 2;
for (int i = 0; i < edata->nb_ports; i++)
edata->data[i] = eth_prm->host_mac_map[i].mac_port.hw_func;

rte_memcpy(RTE_PTR_ADD(buffer, len), edata, total_sz);

len += total_sz;
Expand Down
16 changes: 10 additions & 6 deletions app/ovs-offload/include/ood_eth_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,27 @@
/* Forward declaration */
struct ood_main_cfg_data;

struct ood_ethdev_host_mac_map {
uint16_t mac_port;
uint16_t host_port;
struct ood_ethdev_port_info {
uint16_t port_id;
uint16_t hw_func;
};

typedef struct ood_ethdev_host_mac_map {
struct ood_ethdev_port_info mac_port;
struct ood_ethdev_port_info host_port;
} ood_ethdev_host_mac_map_t;

typedef struct ood_ethdev_param {
int numa_on; /**< NUMA is enabled by default. */
struct rte_mempool *pktmbuf_pool[RTE_MAX_ETHPORTS][OOD_NB_SOCKETS];
/* list of enabled ports */
struct ood_ethdev_host_mac_map host_mac_map[RTE_MAX_ETHPORTS];
uint16_t hw_func[RTE_MAX_ETHPORTS];
ood_ethdev_host_mac_map_t host_mac_map[RTE_MAX_ETHPORTS / 2];
uint16_t nb_ports;
} ood_ethdev_param_t;

int ood_ethdev_init(struct ood_main_cfg_data *ood_main_cfg);
int ood_config_port_max_pkt_len(ood_config_param_t *cfg_prm, struct rte_eth_conf *conf,
struct rte_eth_dev_info *dev_info);
uint16_t ood_ethdev_port_pair_get(struct ood_ethdev_host_mac_map *host_mac_map, uint16_t portid);
uint16_t ood_ethdev_port_pair_get(ood_ethdev_host_mac_map_t *host_mac_map, uint16_t portid);

#endif /* __OOD_ETH_INIT_H__ */
6 changes: 3 additions & 3 deletions app/ovs-offload/init/ood_ctrl_chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ ood_control_channel_init(struct ood_main_cfg_data *ood_main_cfg)
ood_repr_param_t *repr_prm;
ood_ethdev_param_t *eth_prm;
ood_config_param_t *cfg_prm;
struct ood_ethdev_host_mac_map *host_mac_lkp_tbl;
ood_ethdev_host_mac_map_t *host_mac_lkp_tbl;
int i, nb_port;

eth_prm = ood_main_cfg->eth_prm;
Expand All @@ -272,8 +272,8 @@ ood_control_channel_init(struct ood_main_cfg_data *ood_main_cfg)

for (i = 0; i < nb_port; i++) {
repr_qid = i;
rep_map[repr_qid].host_port = host_mac_lkp_tbl[i].host_port;
rep_map[repr_qid].mac_port = host_mac_lkp_tbl[i].mac_port;
rep_map[repr_qid].host_port = host_mac_lkp_tbl[i].host_port.port_id;
rep_map[repr_qid].mac_port = host_mac_lkp_tbl[i].mac_port.port_id;
/* Linked list for storing host and mac ports */
STAILQ_INIT(&rep_map[repr_qid].flow_list);
}
Expand Down
85 changes: 54 additions & 31 deletions app/ovs-offload/init/ood_eth_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,15 @@ is_host_port(uint16_t portid)
}

uint16_t
ood_ethdev_port_pair_get(struct ood_ethdev_host_mac_map *host_mac_map, uint16_t portid)
ood_ethdev_port_pair_get(ood_ethdev_host_mac_map_t *host_mac_map, uint16_t portid)
{
uint16_t i;

for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
if (host_mac_map[i].host_port == portid)
return host_mac_map[i].mac_port;
if (host_mac_map[i].mac_port == portid)
return host_mac_map[i].host_port;
for (i = 0; i < (RTE_MAX_ETHPORTS / 2); i++) {
if (host_mac_map[i].host_port.port_id == portid)
return host_mac_map[i].mac_port.port_id;
if (host_mac_map[i].mac_port.port_id == portid)
return host_mac_map[i].host_port.port_id;
}

return i;
Expand All @@ -535,7 +535,7 @@ ood_ethdev_init(struct ood_main_cfg_data *ood_main_cfg)
ood_lcore_param_t *lcore_prm;
ood_ethdev_param_t *eth_prm;
ood_config_param_t *cfg_prm;
int rc, i = 0;
int rc, idx = 0, i = 0;

eth_prm = ood_main_cfg->eth_prm;
cfg_prm = ood_main_cfg->cfg_prm;
Expand Down Expand Up @@ -579,29 +579,56 @@ ood_ethdev_init(struct ood_main_cfg_data *ood_main_cfg)

/* populate destination port details */
if (cfg_prm->nb_port_pair_params) {
uint16_t idx, p, portid2;
uint16_t p, portid2;

for (idx = i = 0; idx < (cfg_prm->nb_port_pair_params << 1); (idx = idx + 2), i++) {
for (idx = i = 0;
(idx < (cfg_prm->nb_port_pair_params << 1) &&
(i < cfg_prm->nb_port_pair_params));
(idx = idx + 2), i++) {
p = idx & 1;
portid = cfg_prm->port_pair_param[idx >> 1].port[p];
portid2 = cfg_prm->port_pair_param[idx >> 1].port[p ^ 1];

eth_prm->host_mac_map[i].host_port =
eth_prm->host_mac_map[i].host_port.port_id =
is_host_port(portid) ? portid : portid2;
eth_prm->host_mac_map[i].mac_port = is_host_port(portid) ? portid2 : portid;

eth_prm->host_mac_map[i].mac_port.port_id =
is_host_port(portid) ? portid2 : portid;

rte_eth_dev_get_name_by_port(eth_prm->host_mac_map[i].host_port.port_id,
if_name);
eth_prm->host_mac_map[i].host_port.hw_func =
dao_pci_bdf_to_hw_func(if_name);

rte_eth_dev_get_name_by_port(eth_prm->host_mac_map[i].mac_port.port_id,
if_name);
eth_prm->host_mac_map[i].mac_port.hw_func = dao_pci_bdf_to_hw_func(if_name);

dao_info("MAC Port ID %d (%s) -> Host Port ID %d",
eth_prm->host_mac_map[i].mac_port.port_id, if_name,
eth_prm->host_mac_map[i].host_port.port_id);
}
} else {
/* TODO revisit, should be removed */
uint16_t idx = 0;
RTE_ETH_FOREACH_DEV(portid) {
if (portid == ood_repr_get_eswitch_portid(ood_main_cfg))
continue;

if (nb_ports_in_mask % 2) {
eth_prm->host_mac_map[idx].host_port =
eth_prm->host_mac_map[idx].host_port.port_id =
is_host_port(portid) ? portid : last_port;
eth_prm->host_mac_map[idx].mac_port =
eth_prm->host_mac_map[idx].mac_port.port_id =
is_host_port(portid) ? last_port : portid;

rte_eth_dev_get_name_by_port(
eth_prm->host_mac_map[idx].host_port.port_id, if_name);
eth_prm->host_mac_map[idx].host_port.hw_func =
dao_pci_bdf_to_hw_func(if_name);

rte_eth_dev_get_name_by_port(
eth_prm->host_mac_map[idx].mac_port.port_id, if_name);
eth_prm->host_mac_map[idx].mac_port.hw_func =
dao_pci_bdf_to_hw_func(if_name);
} else {
last_port = portid;
}
Expand All @@ -611,33 +638,29 @@ ood_ethdev_init(struct ood_main_cfg_data *ood_main_cfg)
}
if (nb_ports_in_mask % 2) {
dao_warn("Notice: odd number of ports in portmask.");
if (is_host_port(last_port))
eth_prm->host_mac_map[idx].host_port = last_port;
else
eth_prm->host_mac_map[idx].mac_port = last_port;
rte_eth_dev_get_name_by_port(last_port, if_name);
if (is_host_port(last_port)) {
eth_prm->host_mac_map[idx].host_port.port_id = last_port;
eth_prm->host_mac_map[idx].host_port.hw_func =
dao_pci_bdf_to_hw_func(if_name);
} else {
eth_prm->host_mac_map[idx].mac_port.port_id = last_port;
eth_prm->host_mac_map[idx].mac_port.hw_func =
dao_pci_bdf_to_hw_func(if_name);
}
}
cfg_prm->nb_port_pair_params = nb_ports_in_mask / 2;
}
eth_prm->nb_ports = idx;

/* Port pairs together represents VF representor ports */
ood_repr_set_nb_representors(ood_main_cfg, cfg_prm->nb_port_pair_params);

RTE_ETH_FOREACH_DEV(portid) {
if (portid == ood_repr_get_eswitch_portid(ood_main_cfg))
continue;
rte_eth_dev_get_name_by_port(portid, if_name);
eth_prm->hw_func[i++] = dao_pci_bdf_to_hw_func(if_name);
dao_info("MAC Port ID %d (%s) -> Host Port ID %d",
eth_prm->host_mac_map[portid].mac_port, if_name,
eth_prm->host_mac_map[portid].host_port);
}
eth_prm->nb_ports = i;

/* Normal forwarding table setup */
ood_main_cfg->graph_prm->fm_ctrl_cfg.nb_ports = nb_ports;
for (portid = 0; portid < cfg_prm->nb_port_pair_params; portid++) {
host_port = eth_prm->host_mac_map[portid].host_port;
mac_port = eth_prm->host_mac_map[portid].mac_port;
host_port = eth_prm->host_mac_map[portid].host_port.port_id;
mac_port = eth_prm->host_mac_map[portid].mac_port.port_id;

ood_main_cfg->graph_prm->fm_ctrl_cfg.host_mac_map[host_port] = mac_port;
ood_main_cfg->graph_prm->fm_ctrl_cfg.host_mac_map[mac_port] = host_port;
Expand Down

0 comments on commit 51fc63f

Please sign in to comment.