[4/9] net/cnxk: callbacks for representor state
Checks
Commit Message
Implementing the callbacks for processing representor state.
Three operations currently supported:
- set a representor to be active if its VF is enabled and set
it appropriate pf func value.
- check if the VF which sent a mbox has a representor
- clear representor state if its VF goes down.
Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
drivers/net/cnxk/cnxk_rep.c | 65 +++++++++++++++++++++++++++++++++++++
drivers/net/cnxk/cnxk_rep.h | 4 +++
2 files changed, 69 insertions(+)
@@ -39,6 +39,7 @@ cnxk_rep_dev_remove(struct rte_eth_dev *pf_ethdev)
struct cnxk_eth_dev *pf_dev = cnxk_eth_pmd_priv(pf_ethdev);
int rc = 0;
+ roc_nix_process_rep_state_cb_unregister(&pf_dev->nix);
rc = rte_eth_switch_domain_free(pf_dev->switch_domain_id);
if (rc)
plt_err("Failed to alloc switch domain: %d", rc);
@@ -183,6 +184,63 @@ cnxk_rep_dev_init(struct rte_eth_dev *eth_dev, void *params)
return 0;
}
+static int
+cnxk_process_representor_status(void *roc_nix, uint16_t pf_func, uint8_t op)
+{
+ struct cnxk_eth_dev *pf_dev = (struct cnxk_eth_dev *)roc_nix;
+ struct cnxk_rep_dev *rep_dev = NULL;
+ struct rte_eth_dev *rep_eth_dev;
+ uint16_t match = 0, func_val;
+ bool is_vf_active;
+ int i, rc = 0;
+
+ if (!pf_dev) {
+ plt_err("Failed to get PF ethdev handle");
+ return -1;
+ }
+
+ switch (op) {
+ case 0: /* update pffunc of vf being represented */
+ match = 0;
+ func_val = pf_func;
+ is_vf_active = true;
+ break;
+ case 1: /* check if any representor is representing pffunc */
+ match = pf_func;
+ func_val = pf_func;
+ is_vf_active = true;
+ break;
+ case 2: /* vf is going down, reset rep state */
+ match = pf_func;
+ func_val = 0;
+ is_vf_active = false;
+ break;
+ default:
+ plt_err("Invalid op received %d pf_func %x", op, pf_func);
+ return -1;
+ };
+
+ for (i = 0; i < pf_dev->num_reps; i++) {
+ rep_eth_dev = pf_dev->rep_info[i].rep_eth_dev;
+ if (!rep_eth_dev) {
+ plt_err("Failed to get rep ethdev handle");
+ return -1;
+ }
+
+ rep_dev = cnxk_rep_pmd_priv(rep_eth_dev);
+ if (rep_dev->pf_func == match) {
+ plt_base_dbg("Representor port %d op %d match %d func_val %d vf_active %d",
+ i, op, match, func_val, is_vf_active);
+ rep_dev->pf_func = func_val;
+ rep_dev->is_vf_active = is_vf_active;
+ rc = 1;
+ break;
+ }
+ }
+
+ return rc;
+}
+
int
cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *pf_ethdev,
struct rte_eth_devargs *eth_da)
@@ -256,6 +314,13 @@ cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *pf_ethdev
pf_dev->num_reps++;
}
+ /* Register up msg callbacks for processing representor information */
+ if (roc_nix_process_rep_state_cb_register(&pf_dev->nix, cnxk_process_representor_status)) {
+ plt_err("Failed to register callback for representor status");
+ rc = -EINVAL;
+ goto err;
+ }
+
return 0;
err:
return rc;
@@ -17,6 +17,10 @@ struct cnxk_rep_dev {
uint16_t vf_id;
uint16_t switch_domain_id;
struct rte_eth_dev *parent_dev;
+ struct rte_mempool *ctrl_chan_pool;
+ uint16_t rep_xport_vdev;
+ bool is_vf_active;
+ uint16_t pf_func;
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
};