2024-04-16 05:08:02

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 0/9] Introduce RVU representors

This series adds representor support for each rvu devices.
When switchdev mode is enabled, representor netdev is registered
for each rvu device. In implementation of representor model,
one NIX HW LF with multiple SQ and RQ is reserved, where each
RQ and SQ of the LF are mapped to a representor. A loopback channel
is reserved to support packet path between representors and VFs.
CN10K silicon supports 2 types of MACs, RPM and SDP. This
patch set adds representor support for both RPM and SDP MAC
interfaces.

- Patch 1: Refactors and exports the shared service functions.
- patch 2: Implements basic representor driver.
- patch 3: Add devlink support to create representor netdevs that
can be used to manage VFs.
- patch 4: Implements basec netdev_ndo_ops.
- Patch 5: Installs tcam rules to route packets between representor and
VFs.
- patch 6: Enables fetching VF stats via representor interface
- Patch 7: Adds support to sync link state between representors and VFs .
- patch 8: Enables configuring VF MTU via representor netdevs.
- patch 9: Add representors for sdp MAC

Geetha sowjanya (9):
octeontx2-pf: Refactoring RVU driver
octeontx2-pf: RVU representor driver
octeontx2-pf: Create representor netdev
octeontx2-pf: Add basic net_device_ops
octeontx2-af: Add packet path between representor and VF
octeontx2-pf: Get VF stats via representor
octeontx2-pf: Add support to sync link state between representor and
VFs
octeontx2-pf: Configure VF mtu via representor
octeontx2-pf: Add representors for sdp MAC

.../net/ethernet/marvell/octeontx2/Kconfig | 8 +
.../ethernet/marvell/octeontx2/af/Makefile | 3 +-
.../net/ethernet/marvell/octeontx2/af/mbox.h | 73 +++
.../net/ethernet/marvell/octeontx2/af/npc.h | 1 +
.../net/ethernet/marvell/octeontx2/af/rvu.h | 30 +-
.../marvell/octeontx2/af/rvu_debugfs.c | 27 -
.../marvell/octeontx2/af/rvu_devlink.c | 6 +
.../ethernet/marvell/octeontx2/af/rvu_nix.c | 67 +-
.../marvell/octeontx2/af/rvu_npc_fs.c | 4 +
.../ethernet/marvell/octeontx2/af/rvu_rep.c | 457 +++++++++++++
.../marvell/octeontx2/af/rvu_struct.h | 26 +
.../marvell/octeontx2/af/rvu_switch.c | 20 +-
.../ethernet/marvell/octeontx2/nic/Makefile | 2 +
.../ethernet/marvell/octeontx2/nic/cn10k.c | 4 +-
.../ethernet/marvell/octeontx2/nic/cn10k.h | 2 +-
.../marvell/octeontx2/nic/otx2_common.c | 53 +-
.../marvell/octeontx2/nic/otx2_common.h | 83 ++-
.../marvell/octeontx2/nic/otx2_devlink.c | 48 ++
.../ethernet/marvell/octeontx2/nic/otx2_pf.c | 305 ++++++---
.../ethernet/marvell/octeontx2/nic/otx2_reg.h | 1 +
.../marvell/octeontx2/nic/otx2_txrx.c | 33 +-
.../marvell/octeontx2/nic/otx2_txrx.h | 3 +-
.../ethernet/marvell/octeontx2/nic/otx2_vf.c | 18 +-
.../net/ethernet/marvell/octeontx2/nic/rep.c | 602 ++++++++++++++++++
.../net/ethernet/marvell/octeontx2/nic/rep.h | 51 ++
25 files changed, 1704 insertions(+), 223 deletions(-)
create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/rep.c
create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/rep.h

--
2.25.1



2024-04-16 05:08:31

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

Adds initial devlink support to set/get the switchdev mode.
Representor netdevs are created for each rvu devices when
the switch mode is set to 'switchdev'. These netdevs are
be used to control and configure VFs.

Signed-off-by: Geetha sowjanya <[email protected]>
---
.../marvell/octeontx2/nic/otx2_devlink.c | 48 ++++++
.../net/ethernet/marvell/octeontx2/nic/rep.c | 159 ++++++++++++++++++
.../net/ethernet/marvell/octeontx2/nic/rep.h | 2 +
3 files changed, 209 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
index 4e1130496573..f4f5f5d93c7e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
@@ -76,7 +76,53 @@ static const struct devlink_param otx2_dl_params[] = {
otx2_dl_mcam_count_validate),
};

+#ifdef CONFIG_RVU_ESWITCH
+static int otx2_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
+{
+ struct otx2_devlink *otx2_dl = devlink_priv(devlink);
+ struct otx2_nic *pfvf = otx2_dl->pfvf;
+
+ if (!is_rep_dev(pfvf->pdev))
+ return -EOPNOTSUPP;
+
+ *mode = pfvf->esw_mode;
+
+ return 0;
+}
+
+static int otx2_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
+ struct netlink_ext_ack *extack)
+{
+ struct otx2_devlink *otx2_dl = devlink_priv(devlink);
+ struct otx2_nic *pfvf = otx2_dl->pfvf;
+
+ if (!is_rep_dev(pfvf->pdev))
+ return -EOPNOTSUPP;
+
+ if (pfvf->esw_mode == mode)
+ return 0;
+
+ pfvf->esw_mode = mode;
+ switch (mode) {
+ case DEVLINK_ESWITCH_MODE_LEGACY:
+ rvu_rep_destroy(pfvf);
+ break;
+ case DEVLINK_ESWITCH_MODE_SWITCHDEV:
+ rvu_rep_create(pfvf);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+#endif
+
static const struct devlink_ops otx2_devlink_ops = {
+#ifdef CONFIG_RVU_ESWITCH
+ .eswitch_mode_get = otx2_devlink_eswitch_mode_get,
+ .eswitch_mode_set = otx2_devlink_eswitch_mode_set,
+#endif
};

int otx2_register_dl(struct otx2_nic *pfvf)
@@ -112,6 +158,7 @@ int otx2_register_dl(struct otx2_nic *pfvf)
devlink_free(dl);
return err;
}
+EXPORT_SYMBOL(otx2_register_dl);

void otx2_unregister_dl(struct otx2_nic *pfvf)
{
@@ -123,3 +170,4 @@ void otx2_unregister_dl(struct otx2_nic *pfvf)
ARRAY_SIZE(otx2_dl_params));
devlink_free(dl);
}
+EXPORT_SYMBOL(otx2_unregister_dl);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index b892a7fe3ddc..fd55ef40c934 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -28,6 +28,159 @@ MODULE_DESCRIPTION(DRV_STRING);
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);

+static int rvu_rep_napi_init(struct otx2_nic *priv)
+{
+ struct otx2_cq_poll *cq_poll = NULL;
+ struct otx2_qset *qset = &priv->qset;
+ struct otx2_hw *hw = &priv->hw;
+ int err = 0, qidx, vec;
+ char *irq_name;
+
+ qset->napi = kcalloc(hw->cint_cnt, sizeof(*cq_poll), GFP_KERNEL);
+ if (!qset->napi)
+ return -ENOMEM;
+
+ /* Register NAPI handler */
+ for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
+ cq_poll = &qset->napi[qidx];
+ cq_poll->cint_idx = qidx;
+ cq_poll->cq_ids[CQ_RX] =
+ (qidx < hw->rx_queues) ? qidx : CINT_INVALID_CQ;
+ cq_poll->cq_ids[CQ_TX] = (qidx < hw->tx_queues) ?
+ qidx + hw->rx_queues : CINT_INVALID_CQ;
+ cq_poll->cq_ids[CQ_XDP] = CINT_INVALID_CQ;
+ cq_poll->cq_ids[CQ_QOS] = CINT_INVALID_CQ;
+
+ cq_poll->dev = (void *)priv;
+ netif_napi_add(priv->reps[qidx]->netdev, &cq_poll->napi,
+ otx2_napi_handler);
+ napi_enable(&cq_poll->napi);
+ }
+ /* Register CQ IRQ handlers */
+ vec = hw->nix_msixoff + NIX_LF_CINT_VEC_START;
+ for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
+ irq_name = &hw->irq_name[vec * NAME_SIZE];
+
+ snprintf(irq_name, NAME_SIZE, "rep%d-rxtx-%d", qidx, qidx);
+
+ err = request_irq(pci_irq_vector(priv->pdev, vec),
+ otx2_cq_intr_handler, 0, irq_name,
+ &qset->napi[qidx]);
+ if (err) {
+ dev_err(priv->dev,
+ "RVU REP IRQ registration failed for CQ%d\n", qidx);
+ goto err_free_cints;
+ }
+ vec++;
+
+ /* Enable CQ IRQ */
+ otx2_write64(priv, NIX_LF_CINTX_INT(qidx), BIT_ULL(0));
+ otx2_write64(priv, NIX_LF_CINTX_ENA_W1S(qidx), BIT_ULL(0));
+ }
+ priv->flags &= ~OTX2_FLAG_INTF_DOWN;
+ return 0;
+
+err_free_cints:
+ otx2_free_cints(priv, qidx);
+ otx2_disable_napi(priv);
+ return err;
+}
+
+static void rvu_rep_free_cq_rsrc(struct otx2_nic *priv)
+{
+ struct otx2_cq_poll *cq_poll = NULL;
+ struct otx2_qset *qset = &priv->qset;
+ int qidx, vec;
+
+ /* Cleanup CQ NAPI and IRQ */
+ vec = priv->hw.nix_msixoff + NIX_LF_CINT_VEC_START;
+ for (qidx = 0; qidx < priv->hw.cint_cnt; qidx++) {
+ /* Disable interrupt */
+ otx2_write64(priv, NIX_LF_CINTX_ENA_W1C(qidx), BIT_ULL(0));
+
+ synchronize_irq(pci_irq_vector(priv->pdev, vec));
+
+ cq_poll = &qset->napi[qidx];
+ napi_synchronize(&cq_poll->napi);
+ vec++;
+ }
+ otx2_free_cints(priv, priv->hw.cint_cnt);
+ otx2_disable_napi(priv);
+}
+
+static void rvu_rep_free_netdev(struct otx2_nic *priv)
+{
+ struct rep_dev *rep;
+ int rep_id;
+
+ for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++) {
+ rep = priv->reps[rep_id];
+ if (rep && rep->netdev->netdev_ops) {
+ unregister_netdev(rep->netdev);
+ free_netdev(rep->netdev);
+ }
+ }
+ devm_kfree(priv->dev, priv->reps);
+}
+
+void rvu_rep_destroy(struct otx2_nic *priv)
+{
+ rvu_rep_free_cq_rsrc(priv);
+ rvu_rep_free_netdev(priv);
+}
+
+int rvu_rep_create(struct otx2_nic *priv)
+{
+ int rep_cnt = priv->rep_cnt;
+ struct net_device *ndev;
+ struct rep_dev *rep;
+ int rep_id, err;
+ u16 pcifunc;
+
+ priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
+ if (!priv->reps)
+ return -ENOMEM;
+
+ for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
+ ndev = alloc_etherdev(sizeof(*rep));
+ if (!ndev) {
+ dev_err(priv->dev, "PFVF representor:%d creation failed\n", rep_id);
+ err = -ENOMEM;
+ goto exit;
+ }
+
+ rep = netdev_priv(ndev);
+ priv->reps[rep_id] = rep;
+ rep->mdev = priv;
+ rep->netdev = ndev;
+ rep->rep_id = rep_id;
+
+ ndev->min_mtu = OTX2_MIN_MTU;
+ ndev->max_mtu = priv->hw.max_mtu;
+ pcifunc = priv->rep_pf_map[rep_id];
+ rep->pcifunc = pcifunc;
+
+ snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
+ rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
+
+ eth_hw_addr_random(ndev);
+ if (register_netdev(ndev)) {
+ dev_err(priv->dev, "PFVF reprentator registration failed\n");
+ free_netdev(ndev);
+ ndev->netdev_ops = NULL;
+ goto exit;
+ }
+ }
+ err = rvu_rep_napi_init(priv);
+ if (err)
+ goto exit;
+
+ return 0;
+exit:
+ rvu_rep_free_netdev(priv);
+ return err;
+}
+
static int rvu_rep_rsrc_free(struct otx2_nic *priv)
{
struct otx2_qset *qset = &priv->qset;
@@ -162,6 +315,10 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (err)
goto err_detach_rsrc;

+ err = otx2_register_dl(priv);
+ if (err)
+ goto err_detach_rsrc;
+
return 0;

err_detach_rsrc:
@@ -183,6 +340,8 @@ static void rvu_rep_remove(struct pci_dev *pdev)
{
struct otx2_nic *priv = pci_get_drvdata(pdev);

+ otx2_unregister_dl(priv);
+ rvu_rep_destroy(priv);
rvu_rep_rsrc_free(priv);
otx2_detach_resources(&priv->mbox);
if (priv->hw.lmt_info)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
index 30cce17eb48b..be6c939e5cba 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
@@ -29,4 +29,6 @@ static inline bool is_rep_dev(struct pci_dev *pdev)
return pdev->device == PCI_DEVID_RVU_REP;
}

+int rvu_rep_create(struct otx2_nic *priv);
+void rvu_rep_destroy(struct otx2_nic *priv);
#endif /* REP_H */
--
2.25.1


2024-04-16 05:08:51

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 7/9] octeontx2-pf: Add support to sync link state between representor and VFs

Implements mbox function to sync the link state between VFs and
its representors. Same mbox is use to notify other updates like mtu etc.

This patch enables
- Reflecting the link state of representor based on the VF state and
link state of VF based on representor.
- On VF interface up/down a notification is sent via mbox to representor
to update the link state.
- On representor interafce up/down will cause the link state update of VF.

Signed-off-by: Harman Kalra <[email protected]>
Signed-off-by: Geetha sowjanya <[email protected]>
---
.../net/ethernet/marvell/octeontx2/af/mbox.h | 25 ++++
.../net/ethernet/marvell/octeontx2/af/rvu.h | 11 ++
.../ethernet/marvell/octeontx2/af/rvu_nix.c | 6 +
.../ethernet/marvell/octeontx2/af/rvu_rep.c | 127 ++++++++++++++++++
.../marvell/octeontx2/nic/otx2_common.h | 2 +
.../ethernet/marvell/octeontx2/nic/otx2_pf.c | 30 +++++
.../net/ethernet/marvell/octeontx2/nic/rep.c | 76 +++++++++++
.../net/ethernet/marvell/octeontx2/nic/rep.h | 3 +
8 files changed, 280 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index b7f250d218d9..8f099b05ba10 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -145,6 +145,7 @@ M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
M(PTP_GET_CAP, 0x00c, ptp_get_cap, msg_req, ptp_get_cap_rsp) \
M(GET_REP_CNT, 0x00d, get_rep_cnt, msg_req, get_rep_cnt_rsp) \
M(ESW_CFG, 0x00e, esw_cfg, esw_cfg_req, msg_rsp) \
+M(REP_EVENT_NOTIFY, 0x00f, rep_event_notify, rep_event, msg_rsp) \
/* CGX mbox IDs (range 0x200 - 0x3FF) */ \
M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
@@ -382,12 +383,16 @@ M(CPT_INST_LMTST, 0xD00, cpt_inst_lmtst, cpt_inst_lmtst_req, msg_rsp)
#define MBOX_UP_MCS_MESSAGES \
M(MCS_INTR_NOTIFY, 0xE00, mcs_intr_notify, mcs_intr_info, msg_rsp)

+#define MBOX_UP_REP_MESSAGES \
+M(REP_EVENT_UP_NOTIFY, 0xEF0, rep_event_up_notify, rep_event, msg_rsp) \
+
enum {
#define M(_name, _id, _1, _2, _3) MBOX_MSG_ ## _name = _id,
MBOX_MESSAGES
MBOX_UP_CGX_MESSAGES
MBOX_UP_CPT_MESSAGES
MBOX_UP_MCS_MESSAGES
+MBOX_UP_REP_MESSAGES
#undef M
};

@@ -1571,6 +1576,26 @@ struct esw_cfg_req {
u64 rsvd;
};

+struct rep_evt_data {
+ u8 port_state;
+ u8 vf_state;
+ u16 rx_mode;
+ u16 rx_flags;
+ u16 mtu;
+ u64 rsvd[5];
+};
+
+struct rep_event {
+ struct mbox_msghdr hdr;
+ u16 pcifunc;
+#define RVU_EVENT_PORT_STATE BIT_ULL(0)
+#define RVU_EVENT_PFVF_STATE BIT_ULL(1)
+#define RVU_EVENT_MTU_CHANGE BIT_ULL(2)
+#define RVU_EVENT_RX_MODE_CHANGE BIT_ULL(3)
+ u16 event;
+ struct rep_evt_data evt_data;
+};
+
struct flow_msg {
unsigned char dmac[6];
unsigned char smac[6];
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index c8572d79a968..7556ce0a772e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -512,6 +512,11 @@ struct rvu_switch {
u16 start_entry;
};

+struct rep_evtq_ent {
+ struct list_head node;
+ struct rep_event event;
+};
+
struct rvu {
void __iomem *afreg_base;
void __iomem *pfreg_base;
@@ -597,6 +602,11 @@ struct rvu {
int rep_cnt;
u16 *rep2pfvf_map;
u8 rep_mode;
+ struct work_struct rep_evt_work;
+ struct workqueue_struct *rep_evt_wq;
+ struct list_head rep_evtq_head;
+ /* Representor event lock */
+ spinlock_t rep_evtq_lock;
};

static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
@@ -1044,4 +1054,5 @@ void rvu_mcs_exit(struct rvu *rvu);
int rvu_rep_pf_init(struct rvu *rvu);
int rvu_rep_install_mcam_rules(struct rvu *rvu);
void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
+int rvu_rep_notify_pfvf_state(struct rvu *rvu, u16 pcifunc, bool enable);
#endif /* RVU_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 75d5c1bc00e1..6a1602dc11d7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -379,6 +379,9 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf,
cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, pkind);
rvu_npc_set_pkind(rvu, pkind, pfvf);

+ if (rvu->rep_mode)
+ rvu_rep_notify_pfvf_state(rvu, pcifunc, true);
+
break;
case NIX_INTF_TYPE_LBK:
vf = (pcifunc & RVU_PFVF_FUNC_MASK) - 1;
@@ -515,6 +518,9 @@ static void nix_interface_deinit(struct rvu *rvu, u16 pcifunc, u8 nixlf)

/* Disable DMAC filters used */
rvu_cgx_disable_dmac_entries(rvu, pcifunc);
+
+ if (rvu->rep_mode)
+ rvu_rep_notify_pfvf_state(rvu, pcifunc, false);
}

#define NIX_BPIDS_PER_LMAC 8
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
index 103d1d451411..2013a4a0afd0 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
@@ -13,6 +13,124 @@
#include "rvu.h"
#include "rvu_reg.h"

+#define M(_name, _id, _fn_name, _req_type, _rsp_type) \
+static struct _req_type __maybe_unused \
+*otx2_mbox_alloc_msg_ ## _fn_name(struct rvu *rvu, int devid) \
+{ \
+ struct _req_type *req; \
+ \
+ req = (struct _req_type *)otx2_mbox_alloc_msg_rsp( \
+ &rvu->afpf_wq_info.mbox_up, devid, sizeof(struct _req_type), \
+ sizeof(struct _rsp_type)); \
+ if (!req) \
+ return NULL; \
+ req->hdr.sig = OTX2_MBOX_REQ_SIG; \
+ req->hdr.id = _id; \
+ return req; \
+}
+
+MBOX_UP_REP_MESSAGES
+#undef M
+
+static int rvu_rep_up_notify(struct rvu *rvu, struct rep_event *event)
+{
+ struct rep_event *msg;
+ int pf;
+
+ pf = rvu_get_pf(event->pcifunc);
+
+ mutex_lock(&rvu->mbox_lock);
+ msg = otx2_mbox_alloc_msg_rep_event_up_notify(rvu, pf);
+ if (!msg) {
+ mutex_unlock(&rvu->mbox_lock);
+ return -ENOMEM;
+ }
+
+ msg->hdr.pcifunc = event->pcifunc;
+ msg->event = event->event;
+
+ memcpy(&msg->evt_data, &event->evt_data, sizeof(struct rep_evt_data));
+
+ otx2_mbox_wait_for_zero(&rvu->afpf_wq_info.mbox_up, pf);
+
+ otx2_mbox_msg_send_up(&rvu->afpf_wq_info.mbox_up, pf);
+
+ mutex_unlock(&rvu->mbox_lock);
+ return 0;
+}
+
+static void rvu_rep_wq_handler(struct work_struct *work)
+{
+ struct rvu *rvu = container_of(work, struct rvu, rep_evt_work);
+ struct rep_evtq_ent *qentry;
+ struct rep_event *event;
+ unsigned long flags;
+
+ do {
+ spin_lock_irqsave(&rvu->rep_evtq_lock, flags);
+ qentry = list_first_entry_or_null(&rvu->rep_evtq_head,
+ struct rep_evtq_ent,
+ node);
+ if (qentry)
+ list_del(&qentry->node);
+
+ spin_unlock_irqrestore(&rvu->rep_evtq_lock, flags);
+ if (!qentry)
+ break; /* nothing more to process */
+
+ event = &qentry->event;
+
+ rvu_rep_up_notify(rvu, event);
+ kfree(qentry);
+ } while (1);
+}
+
+int rvu_mbox_handler_rep_event_notify(struct rvu *rvu, struct rep_event *req,
+ struct msg_rsp *rsp)
+{
+ struct rep_evtq_ent *qentry;
+
+ qentry = kmalloc(sizeof(*qentry), GFP_ATOMIC);
+ if (!qentry)
+ return -ENOMEM;
+
+ qentry->event = *req;
+ spin_lock(&rvu->rep_evtq_lock);
+ list_add_tail(&qentry->node, &rvu->rep_evtq_head);
+ spin_unlock(&rvu->rep_evtq_lock);
+ queue_work(rvu->rep_evt_wq, &rvu->rep_evt_work);
+ return 0;
+}
+
+int rvu_rep_notify_pfvf_state(struct rvu *rvu, u16 pcifunc, bool enable)
+{
+ struct rep_event *req;
+ int pf;
+
+ if (!is_pf_cgxmapped(rvu, rvu_get_pf(pcifunc)))
+ return 0;
+
+ pf = rvu_get_pf(rvu->rep_pcifunc);
+
+ mutex_lock(&rvu->mbox_lock);
+ req = otx2_mbox_alloc_msg_rep_event_up_notify(rvu, pf);
+ if (!req) {
+ mutex_unlock(&rvu->mbox_lock);
+ return -ENOMEM;
+ }
+
+ req->hdr.pcifunc = rvu->rep_pcifunc;
+ req->event |= RVU_EVENT_PFVF_STATE;
+ req->pcifunc = pcifunc;
+ req->evt_data.vf_state = enable;
+
+ otx2_mbox_wait_for_zero(&rvu->afpf_wq_info.mbox_up, pf);
+ otx2_mbox_msg_send_up(&rvu->afpf_wq_info.mbox_up, pf);
+
+ mutex_unlock(&rvu->mbox_lock);
+ return 0;
+}
+
#define RVU_LF_RX_STATS(reg) \
rvu_read64(rvu, blkaddr, NIX_AF_LFX_RX_STATX(nixlf, reg))

@@ -241,6 +359,15 @@ int rvu_rep_install_mcam_rules(struct rvu *rvu)
}
}
}
+
+ /* Initialize the wq for handling REP events */
+ INIT_LIST_HEAD(&rvu->rep_evtq_head);
+ INIT_WORK(&rvu->rep_evt_work, rvu_rep_wq_handler);
+ rvu->rep_evt_wq = alloc_workqueue("rep_evt_wq", 0, 0);
+ if (!rvu->rep_evt_wq) {
+ dev_err(rvu->dev, "REP workqueue allocation failed\n");
+ return -ENOMEM;
+ }
return 0;
}

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
index 79ec86035c16..865d5d3146a9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
@@ -441,6 +441,7 @@ struct otx2_nic {
#define OTX2_FLAG_PTP_ONESTEP_SYNC BIT_ULL(15)
#define OTX2_FLAG_ADPTV_INT_COAL_ENABLED BIT_ULL(16)
#define OTX2_FLAG_REP_MODE_ENABLED BIT_ULL(17)
+#define OTX2_FLAG_PORT_UP BIT_ULL(18)
u64 flags;
u64 *cq_op_addr;

@@ -1125,4 +1126,5 @@ u16 otx2_select_queue(struct net_device *netdev, struct sk_buff *skb,
int otx2_get_txq_by_classid(struct otx2_nic *pfvf, u16 classid);
void otx2_qos_config_txschq(struct otx2_nic *pfvf);
void otx2_clean_qos_queues(struct otx2_nic *pfvf);
+int rvu_event_up_notify(struct otx2_nic *pf, struct rep_event *info);
#endif /* OTX2_COMMON_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 119c99768a85..2a1bc8cdea19 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -519,6 +519,7 @@ static void otx2_pfvf_mbox_up_handler(struct work_struct *work)

switch (msg->id) {
case MBOX_MSG_CGX_LINK_EVENT:
+ case MBOX_MSG_REP_EVENT_UP_NOTIFY:
break;
default:
if (msg->rc)
@@ -832,6 +833,9 @@ static void otx2_handle_link_event(struct otx2_nic *pf)
struct cgx_link_user_info *linfo = &pf->linfo;
struct net_device *netdev = pf->netdev;

+ if (pf->flags & OTX2_FLAG_PORT_UP)
+ return;
+
pr_info("%s NIC Link is %s %d Mbps %s duplex\n", netdev->name,
linfo->link_up ? "UP" : "DOWN", linfo->speed,
linfo->full_duplex ? "Full" : "Half");
@@ -844,6 +848,30 @@ static void otx2_handle_link_event(struct otx2_nic *pf)
}
}

+static int otx2_mbox_up_handler_rep_event_up_notify(struct otx2_nic *pf,
+ struct rep_event *info,
+ struct msg_rsp *rsp)
+{
+ struct net_device *netdev = pf->netdev;
+
+ if (info->event == RVU_EVENT_PORT_STATE) {
+ if (info->evt_data.port_state) {
+ pf->flags |= OTX2_FLAG_PORT_UP;
+ netif_carrier_on(netdev);
+ netif_tx_start_all_queues(netdev);
+ } else {
+ pf->flags &= ~OTX2_FLAG_PORT_UP;
+ netif_tx_stop_all_queues(netdev);
+ netif_carrier_off(netdev);
+ }
+ return 0;
+ }
+#ifdef CONFIG_RVU_ESWITCH
+ rvu_event_up_notify(pf, info);
+#endif
+ return 0;
+}
+
int otx2_mbox_up_handler_mcs_intr_notify(struct otx2_nic *pf,
struct mcs_intr_info *event,
struct msg_rsp *rsp)
@@ -913,6 +941,7 @@ static int otx2_process_mbox_msg_up(struct otx2_nic *pf,
}
MBOX_UP_CGX_MESSAGES
MBOX_UP_MCS_MESSAGES
+MBOX_UP_REP_MESSAGES
#undef M
break;
default:
@@ -1967,6 +1996,7 @@ int otx2_open(struct net_device *netdev)
}

pf->flags &= ~OTX2_FLAG_INTF_DOWN;
+ pf->flags &= ~OTX2_FLAG_PORT_UP;
/* 'intf_down' may be checked on any cpu */
smp_wmb();

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index 3a6a85ae47e5..2677a229a9e7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -28,6 +28,57 @@ MODULE_DESCRIPTION(DRV_STRING);
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);

+static int rvu_rep_get_repid(struct otx2_nic *priv, u16 pcifunc)
+{
+ int rep_id;
+
+ for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++)
+ if (priv->rep_pf_map[rep_id] == pcifunc)
+ return rep_id;
+ return -EINVAL;
+}
+
+static int rvu_rep_notify_pfvf(struct otx2_nic *priv, u16 event,
+ struct rep_event *data)
+{
+ struct rep_event *req;
+
+ mutex_lock(&priv->mbox.lock);
+ req = otx2_mbox_alloc_msg_rep_event_notify(&priv->mbox);
+ if (!req) {
+ mutex_unlock(&priv->mbox.lock);
+ return -ENOMEM;
+ }
+ req->event = event;
+ req->pcifunc = data->pcifunc;
+
+ memcpy(&req->evt_data, &data->evt_data, sizeof(struct rep_evt_data));
+ otx2_sync_mbox_msg(&priv->mbox);
+ mutex_unlock(&priv->mbox.lock);
+ return 0;
+}
+
+static void rvu_rep_state_evt_handler(struct otx2_nic *priv,
+ struct rep_event *info)
+{
+ struct rep_dev *rep;
+ int rep_id;
+
+ rep_id = rvu_rep_get_repid(priv, info->pcifunc);
+ rep = priv->reps[rep_id];
+ if (info->evt_data.vf_state)
+ rep->flags |= RVU_REP_VF_INITIALIZED;
+ else
+ rep->flags &= ~RVU_REP_VF_INITIALIZED;
+}
+
+int rvu_event_up_notify(struct otx2_nic *pf, struct rep_event *info)
+{
+ if (info->event & RVU_EVENT_PFVF_STATE)
+ rvu_rep_state_evt_handler(pf, info);
+ return 0;
+}
+
static void rvu_rep_get_stats(struct work_struct *work)
{
struct delayed_work *del_work = to_delayed_work(work);
@@ -77,6 +128,9 @@ static void rvu_rep_get_stats64(struct net_device *dev, struct rtnl_link_stats64
{
struct rep_dev *rep = netdev_priv(dev);

+ if (!(rep->flags & RVU_REP_VF_INITIALIZED))
+ return;
+
stats->rx_packets = rep->stats.rx_frames;
stats->rx_bytes = rep->stats.rx_bytes;
stats->rx_dropped = rep->stats.rx_drops;
@@ -131,16 +185,38 @@ static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device *dev)

static int rvu_rep_open(struct net_device *dev)
{
+ struct rep_dev *rep = netdev_priv(dev);
+ struct otx2_nic *priv = rep->mdev;
+ struct rep_event evt = {0};
+
+ if (!(rep->flags & RVU_REP_VF_INITIALIZED))
+ return 0;
+
netif_carrier_on(dev);
netif_tx_start_all_queues(dev);
+
+ evt.event = RVU_EVENT_PORT_STATE;
+ evt.evt_data.port_state = 1;
+ evt.pcifunc = rep->pcifunc;
+ rvu_rep_notify_pfvf(priv, RVU_EVENT_PORT_STATE, &evt);
return 0;
}

static int rvu_rep_stop(struct net_device *dev)
{
+ struct rep_dev *rep = netdev_priv(dev);
+ struct otx2_nic *priv = rep->mdev;
+ struct rep_event evt = {0};
+
+ if (!(rep->flags & RVU_REP_VF_INITIALIZED))
+ return 0;
+
netif_carrier_off(dev);
netif_tx_disable(dev);

+ evt.event = RVU_EVENT_PORT_STATE;
+ evt.pcifunc = rep->pcifunc;
+ rvu_rep_notify_pfvf(priv, RVU_EVENT_PORT_STATE, &evt);
return 0;
}

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
index 9526b886b173..c0bbb383ab88 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
@@ -36,6 +36,8 @@ struct rep_dev {
struct delayed_work stats_wrk;
u16 rep_id;
u16 pcifunc;
+#define RVU_REP_VF_INITIALIZED BIT_ULL(0)
+ u8 flags;
};

static inline bool is_rep_dev(struct pci_dev *pdev)
@@ -45,4 +47,5 @@ static inline bool is_rep_dev(struct pci_dev *pdev)

int rvu_rep_create(struct otx2_nic *priv);
void rvu_rep_destroy(struct otx2_nic *priv);
+int rvu_event_up_notify(struct otx2_nic *pf, struct rep_event *info);
#endif /* REP_H */
--
2.25.1


2024-04-16 05:08:52

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 5/9] octeontx2-af: Add packet path between representor and VF

This patch installs tcam rules to stree traffic representors
and VF when swicthdev mode is set. To support this a HW loopback
channel is reserved. Through this channel packet are routed
between representor and VFs. "ESW_CFG" mbox is defined to
notify AF for installing rules.

Signed-off-by: Geetha sowjanya <[email protected]>
---
.../net/ethernet/marvell/octeontx2/af/mbox.h | 7 +
.../net/ethernet/marvell/octeontx2/af/rvu.h | 7 +-
.../marvell/octeontx2/af/rvu_devlink.c | 6 +
.../ethernet/marvell/octeontx2/af/rvu_nix.c | 7 +-
.../ethernet/marvell/octeontx2/af/rvu_rep.c | 241 +++++++++++++++++-
.../marvell/octeontx2/af/rvu_switch.c | 18 +-
.../net/ethernet/marvell/octeontx2/nic/rep.c | 19 ++
7 files changed, 297 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index c77c02730cf9..3b36da28a8f4 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -144,6 +144,7 @@ M(LMTST_TBL_SETUP, 0x00a, lmtst_tbl_setup, lmtst_tbl_setup_req, \
M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
M(PTP_GET_CAP, 0x00c, ptp_get_cap, msg_req, ptp_get_cap_rsp) \
M(GET_REP_CNT, 0x00d, get_rep_cnt, msg_req, get_rep_cnt_rsp) \
+M(ESW_CFG, 0x00e, esw_cfg, esw_cfg_req, msg_rsp) \
/* CGX mbox IDs (range 0x200 - 0x3FF) */ \
M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
@@ -1532,6 +1533,12 @@ struct get_rep_cnt_rsp {
u64 rsvd;
};

+struct esw_cfg_req {
+ struct mbox_msghdr hdr;
+ u8 ena;
+ u64 rsvd;
+};
+
struct flow_msg {
unsigned char dmac[6];
unsigned char smac[6];
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 1d76d52d7a5d..c8572d79a968 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -596,6 +596,7 @@ struct rvu {
u16 rep_pcifunc;
int rep_cnt;
u16 *rep2pfvf_map;
+ u8 rep_mode;
};

static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
@@ -1025,7 +1026,7 @@ int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr);
/* RVU Switch */
void rvu_switch_enable(struct rvu *rvu);
void rvu_switch_disable(struct rvu *rvu);
-void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc);
+void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
void rvu_switch_enable_lbk_link(struct rvu *rvu, u16 pcifunc, bool ena);

int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir,
@@ -1039,4 +1040,8 @@ int rvu_mcs_flr_handler(struct rvu *rvu, u16 pcifunc);
void rvu_mcs_ptp_cfg(struct rvu *rvu, u8 rpm_id, u8 lmac_id, bool ena);
void rvu_mcs_exit(struct rvu *rvu);

+/* Representor APIs */
+int rvu_rep_pf_init(struct rvu *rvu);
+int rvu_rep_install_mcam_rules(struct rvu *rvu);
+void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
#endif /* RVU_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 96c04f7d93f8..8a3b7fb61883 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -1464,6 +1464,9 @@ static int rvu_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
struct rvu *rvu = rvu_dl->rvu;
struct rvu_switch *rswitch;

+ if (rvu->rep_mode)
+ return -EOPNOTSUPP;
+
rswitch = &rvu->rswitch;
*mode = rswitch->mode;

@@ -1477,6 +1480,9 @@ static int rvu_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
struct rvu *rvu = rvu_dl->rvu;
struct rvu_switch *rswitch;

+ if (rvu->rep_mode)
+ return -EOPNOTSUPP;
+
rswitch = &rvu->rswitch;
switch (mode) {
case DEVLINK_ESWITCH_MODE_LEGACY:
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 4ef5bb7b337f..75d5c1bc00e1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -2738,7 +2738,7 @@ void rvu_nix_tx_tl2_cfg(struct rvu *rvu, int blkaddr, u16 pcifunc,
int schq;
u64 cfg;

- if (!is_pf_cgxmapped(rvu, pf))
+ if (!is_pf_cgxmapped(rvu, pf) && !is_rep_dev(rvu, pcifunc))
return;

cfg = enable ? (BIT_ULL(12) | RVU_SWITCH_LBK_CHAN) : 0;
@@ -4368,8 +4368,6 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
if (test_bit(PF_SET_VF_TRUSTED, &pfvf->flags) && from_vf)
ether_addr_copy(pfvf->default_mac, req->mac_addr);

- rvu_switch_update_rules(rvu, pcifunc);
-
return 0;
}

@@ -5159,7 +5157,7 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
pfvf = rvu_get_pfvf(rvu, pcifunc);
set_bit(NIXLF_INITIALIZED, &pfvf->flags);

- rvu_switch_update_rules(rvu, pcifunc);
+ rvu_switch_update_rules(rvu, pcifunc, true);

return rvu_cgx_start_stop_io(rvu, pcifunc, true);
}
@@ -5187,6 +5185,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
if (err)
return err;

+ rvu_switch_update_rules(rvu, pcifunc, false);
rvu_cgx_tx_enable(rvu, pcifunc, true);

return 0;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
index d07cb356d3d6..5c015e8dfbbe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
@@ -13,6 +13,246 @@
#include "rvu.h"
#include "rvu_reg.h"

+static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
+{
+ int id;
+
+ for (id = 0; id < rvu->rep_cnt; id++)
+ if (rvu->rep2pfvf_map[id] == pcifunc)
+ return id;
+ return -ENODEV;
+}
+
+static int rvu_rep_tx_vlan_cfg(struct rvu *rvu, u16 pcifunc,
+ u16 vlan_tci, int *vidx)
+{
+ struct nix_vtag_config req = {0};
+ struct nix_vtag_config_rsp rsp = {0};
+ u64 etype = ETH_P_8021Q;
+ int err;
+
+ /* Insert vlan tag */
+ req.hdr.pcifunc = pcifunc;
+ req.vtag_size = VTAGSIZE_T4;
+ req.cfg_type = 0; /* tx vlan cfg */
+ req.tx.cfg_vtag0 = true;
+ req.tx.vtag0 = etype << 48 | ntohs(vlan_tci);
+
+ err = rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
+ if (err) {
+ dev_err(rvu->dev, "Tx vlan config failed\n");
+ return err;
+ }
+ *vidx = rsp.vtag0_idx;
+ return 0;
+}
+
+static int rvu_rep_rx_vlan_cfg(struct rvu *rvu, u16 pcifunc)
+{
+ struct nix_vtag_config req = {0};
+ struct nix_vtag_config_rsp rsp;
+
+ /* config strip, capture and size */
+ req.hdr.pcifunc = pcifunc;
+ req.vtag_size = VTAGSIZE_T4;
+ req.cfg_type = 1; /* rx vlan cfg */
+ req.rx.vtag_type = NIX_AF_LFX_RX_VTAG_TYPE0;
+ req.rx.strip_vtag = true;
+ req.rx.capture_vtag = false;
+
+ return rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
+}
+
+static int rvu_rep_install_rx_rule(struct rvu *rvu, u16 pcifunc,
+ u16 entry, bool rte)
+{
+ struct npc_install_flow_req req = { 0 };
+ struct npc_install_flow_rsp rsp = { 0 };
+ struct rvu_pfvf *pfvf;
+ u16 vlan_tci, rep_id;
+
+ pfvf = rvu_get_pfvf(rvu, pcifunc);
+
+ /* To stree the traffic from Representee to Representor */
+ rep_id = (u16)rvu_rep_get_vlan_id(rvu, pcifunc);
+ if (rte) {
+ vlan_tci = rep_id | 0x1ull << 8;
+ req.vf = rvu->rep_pcifunc;
+ req.op = NIX_RX_ACTIONOP_UCAST;
+ req.index = rep_id;
+ } else {
+ vlan_tci = rep_id;
+ req.vf = pcifunc;
+ req.op = NIX_RX_ACTION_DEFAULT;
+ }
+
+ rvu_rep_rx_vlan_cfg(rvu, req.vf);
+ req.entry = entry;
+ req.hdr.pcifunc = 0; /* AF is requester */
+ req.features = BIT_ULL(NPC_OUTER_VID) | BIT_ULL(NPC_VLAN_ETYPE_CTAG);
+ req.vtag0_valid = true;
+ req.vtag0_type = NIX_AF_LFX_RX_VTAG_TYPE0;
+ req.packet.vlan_etype = ETH_P_8021Q;
+ req.mask.vlan_etype = ETH_P_8021Q;
+ req.packet.vlan_tci = vlan_tci;
+ req.mask.vlan_tci = 0xffff;
+
+ req.channel = RVU_SWITCH_LBK_CHAN;
+ req.chan_mask = 0xffff;
+ req.intf = pfvf->nix_rx_intf;
+
+ return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
+}
+
+static int rvu_rep_install_tx_rule(struct rvu *rvu, u16 pcifunc, u16 entry,
+ bool rte)
+{
+ struct npc_install_flow_req req = { 0 };
+ struct npc_install_flow_rsp rsp = { 0 };
+ struct rvu_pfvf *pfvf;
+ int vidx, err;
+ u16 vlan_tci;
+ u8 lbkid;
+
+ pfvf = rvu_get_pfvf(rvu, pcifunc);
+ vlan_tci = rvu_rep_get_vlan_id(rvu, pcifunc);
+ if (rte)
+ vlan_tci |= 0x1ull << 8;
+
+ err = rvu_rep_tx_vlan_cfg(rvu, pcifunc, vlan_tci, &vidx);
+ if (err)
+ return err;
+
+ lbkid = pfvf->nix_blkaddr == BLKADDR_NIX0 ? 0 : 1;
+ req.hdr.pcifunc = 0; /* AF is requester */
+ if (rte) {
+ req.vf = pcifunc;
+ } else {
+ req.vf = rvu->rep_pcifunc;
+ req.packet.sq_id = vlan_tci;
+ req.mask.sq_id = 0xffff;
+ }
+
+ req.entry = entry;
+ req.intf = pfvf->nix_tx_intf;
+ req.op = NIX_TX_ACTIONOP_UCAST_CHAN;
+ req.index = (lbkid << 8) | RVU_SWITCH_LBK_CHAN;
+ req.set_cntr = 1;
+ req.vtag0_def = vidx;
+ req.vtag0_op = 1;
+ return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
+}
+
+int rvu_rep_install_mcam_rules(struct rvu *rvu)
+{
+ struct rvu_switch *rswitch = &rvu->rswitch;
+ u16 start = rswitch->start_entry;
+ struct rvu_hwinfo *hw = rvu->hw;
+ u16 pcifunc, entry = 0;
+ int pf, vf, numvfs;
+ int err, nixlf, i;
+ u8 rep;
+
+ for (pf = 1; pf < hw->total_pfs; pf++) {
+ if (!is_pf_cgxmapped(rvu, pf))
+ continue;
+
+ pcifunc = pf << RVU_PFVF_PF_SHIFT;
+ rvu_get_nix_blkaddr(rvu, pcifunc);
+ rep = true;
+ for (i = 0; i < 2; i++) {
+ err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
+ if (err)
+ return err;
+ rswitch->entry2pcifunc[entry++] = pcifunc;
+
+ err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
+ if (err)
+ return err;
+ rswitch->entry2pcifunc[entry++] = pcifunc;
+ rep = false;
+ }
+
+ rvu_get_pf_numvfs(rvu, pf, &numvfs, NULL);
+ for (vf = 0; vf < numvfs; vf++) {
+ pcifunc = pf << RVU_PFVF_PF_SHIFT |
+ ((vf + 1) & RVU_PFVF_FUNC_MASK);
+ rvu_get_nix_blkaddr(rvu, pcifunc);
+
+ /* Skip installimg rules if nixlf is not attached */
+ err = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
+ if (err)
+ continue;
+ rep = true;
+ for (i = 0; i < 2; i++) {
+ err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
+ if (err)
+ return err;
+ rswitch->entry2pcifunc[entry++] = pcifunc;
+
+ err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
+ if (err)
+ return err;
+ rswitch->entry2pcifunc[entry++] = pcifunc;
+ rep = false;
+ }
+ }
+ }
+ return 0;
+}
+
+void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
+{
+ struct rvu_switch *rswitch = &rvu->rswitch;
+ struct npc_mcam *mcam = &rvu->hw->mcam;
+ u32 max = rswitch->used_entries;
+ int blkaddr;
+ u16 entry;
+
+ if (!rswitch->used_entries)
+ return;
+
+ blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
+
+ if (blkaddr < 0)
+ return;
+
+ rvu_switch_enable_lbk_link(rvu, pcifunc, ena);
+ mutex_lock(&mcam->lock);
+ for (entry = 0; entry < max; entry++) {
+ if (rswitch->entry2pcifunc[entry] == pcifunc)
+ npc_enable_mcam_entry(rvu, mcam, blkaddr, entry, ena);
+ }
+ mutex_unlock(&mcam->lock);
+}
+
+int rvu_rep_pf_init(struct rvu *rvu)
+{
+ u16 pcifunc = rvu->rep_pcifunc;
+ struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
+
+ set_bit(NIXLF_INITIALIZED, &pfvf->flags);
+ rvu_switch_enable_lbk_link(rvu, pcifunc, true);
+ rvu_rep_rx_vlan_cfg(rvu, pcifunc);
+ return 0;
+}
+
+int rvu_mbox_handler_esw_cfg(struct rvu *rvu, struct esw_cfg_req *req,
+ struct msg_rsp *rsp)
+{
+ if (req->hdr.pcifunc != rvu->rep_pcifunc)
+ return 0;
+
+ rvu->rep_mode = req->ena;
+
+ if (req->ena)
+ rvu_switch_enable(rvu);
+ else
+ rvu_switch_disable(rvu);
+
+ return 0;
+}
+
int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
struct get_rep_cnt_rsp *rsp)
{
@@ -45,4 +285,3 @@ int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
}
return 0;
}
-
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
index ceb81eebf65e..268efb7c1c15 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
@@ -166,6 +166,8 @@ void rvu_switch_enable(struct rvu *rvu)

alloc_req.contig = true;
alloc_req.count = rvu->cgx_mapped_pfs + rvu->cgx_mapped_vfs;
+ if (rvu->rep_mode)
+ alloc_req.count = alloc_req.count * 4;
ret = rvu_mbox_handler_npc_mcam_alloc_entry(rvu, &alloc_req,
&alloc_rsp);
if (ret) {
@@ -189,7 +191,12 @@ void rvu_switch_enable(struct rvu *rvu)
rswitch->used_entries = alloc_rsp.count;
rswitch->start_entry = alloc_rsp.entry;

- ret = rvu_switch_install_rules(rvu);
+ if (rvu->rep_mode) {
+ rvu_rep_pf_init(rvu);
+ ret = rvu_rep_install_mcam_rules(rvu);
+ } else {
+ ret = rvu_switch_install_rules(rvu);
+ }
if (ret)
goto uninstall_rules;

@@ -222,6 +229,9 @@ void rvu_switch_disable(struct rvu *rvu)
if (!rswitch->used_entries)
return;

+ if (rvu->rep_mode)
+ goto free_ents;
+
for (pf = 1; pf < hw->total_pfs; pf++) {
if (!is_pf_cgxmapped(rvu, pf))
continue;
@@ -249,6 +259,7 @@ void rvu_switch_disable(struct rvu *rvu)
}
}

+free_ents:
uninstall_req.start = rswitch->start_entry;
uninstall_req.end = rswitch->start_entry + rswitch->used_entries - 1;
free_req.all = 1;
@@ -258,12 +269,15 @@ void rvu_switch_disable(struct rvu *rvu)
kfree(rswitch->entry2pcifunc);
}

-void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc)
+void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
{
struct rvu_switch *rswitch = &rvu->rswitch;
u32 max = rswitch->used_entries;
u16 entry;

+ if (rvu->rep_mode)
+ return rvu_rep_update_rules(rvu, pcifunc, ena);
+
if (!rswitch->used_entries)
return;

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index 187b00156bcd..1329617f8d6f 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -28,6 +28,22 @@ MODULE_DESCRIPTION(DRV_STRING);
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);

+static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
+{
+ struct esw_cfg_req *req;
+
+ mutex_lock(&priv->mbox.lock);
+ req = otx2_mbox_alloc_msg_esw_cfg(&priv->mbox);
+ if (!req) {
+ mutex_unlock(&priv->mbox.lock);
+ return -ENOMEM;
+ }
+ req->ena = ena;
+ otx2_sync_mbox_msg(&priv->mbox);
+ mutex_unlock(&priv->mbox.lock);
+ return 0;
+}
+
static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct rep_dev *rep = netdev_priv(dev);
@@ -170,6 +186,8 @@ static void rvu_rep_free_netdev(struct otx2_nic *priv)

void rvu_rep_destroy(struct otx2_nic *priv)
{
+ /* Remove mcam rules */
+ rvu_eswitch_config(priv, false);
rvu_rep_free_cq_rsrc(priv);
rvu_rep_free_netdev(priv);
}
@@ -221,6 +239,7 @@ int rvu_rep_create(struct otx2_nic *priv)
if (err)
goto exit;

+ rvu_eswitch_config(priv, true);
return 0;
exit:
rvu_rep_free_netdev(priv);
--
2.25.1


2024-04-16 05:09:33

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 6/9] octeontx2-pf: Get VF stats via representor

This patch add support to export VF port statistics via representor
netdev. Defines new mbox "NIX_LF_STATS" to fetch VF hw stats.

Signed-off-by: Geetha sowjanya <[email protected]>
---
.../net/ethernet/marvell/octeontx2/af/mbox.h | 32 ++++++++++
.../ethernet/marvell/octeontx2/af/rvu_rep.c | 43 +++++++++++++
.../net/ethernet/marvell/octeontx2/nic/rep.c | 64 +++++++++++++++++++
.../net/ethernet/marvell/octeontx2/nic/rep.h | 14 ++++
4 files changed, 153 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 3b36da28a8f4..b7f250d218d9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -320,6 +320,7 @@ M(NIX_MCAST_GRP_DESTROY, 0x802c, nix_mcast_grp_destroy, nix_mcast_grp_destroy_re
M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, \
nix_mcast_grp_update_req, \
nix_mcast_grp_update_rsp) \
+M(NIX_LF_STATS, 0x802e, nix_lf_stats, nix_stats_req, nix_stats_rsp) \
/* MCS mbox IDs (range 0xA000 - 0xBFFF) */ \
M(MCS_ALLOC_RESOURCES, 0xa000, mcs_alloc_resources, mcs_alloc_rsrc_req, \
mcs_alloc_rsrc_rsp) \
@@ -1365,6 +1366,37 @@ struct nix_bandprof_get_hwinfo_rsp {
u32 policer_timeunit;
};

+struct nix_stats_req {
+ struct mbox_msghdr hdr;
+ u8 reset;
+ u16 pcifunc;
+ u64 rsvd;
+};
+
+struct nix_stats_rsp {
+ struct mbox_msghdr hdr;
+ u16 pcifunc;
+ struct {
+ u64 octs;
+ u64 ucast;
+ u64 bcast;
+ u64 mcast;
+ u64 drop;
+ u64 drop_octs;
+ u64 drop_mcast;
+ u64 drop_bcast;
+ u64 err;
+ u64 rsvd[5];
+ } rx;
+ struct {
+ u64 ucast;
+ u64 bcast;
+ u64 mcast;
+ u64 drop;
+ u64 octs;
+ } tx;
+};
+
/* NPC mbox message structs */

#define NPC_MCAM_ENTRY_INVALID 0xFFFF
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
index 5c015e8dfbbe..103d1d451411 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
@@ -13,6 +13,49 @@
#include "rvu.h"
#include "rvu_reg.h"

+#define RVU_LF_RX_STATS(reg) \
+ rvu_read64(rvu, blkaddr, NIX_AF_LFX_RX_STATX(nixlf, reg))
+
+#define RVU_LF_TX_STATS(reg) \
+ rvu_read64(rvu, blkaddr, NIX_AF_LFX_TX_STATX(nixlf, reg))
+
+int rvu_mbox_handler_nix_lf_stats(struct rvu *rvu,
+ struct nix_stats_req *req,
+ struct nix_stats_rsp *rsp)
+{
+ u16 pcifunc = req->pcifunc;
+ int nixlf, blkaddr, err;
+ struct msg_req rst_req;
+ struct msg_rsp rst_rsp;
+
+ err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
+ if (err)
+ return 0;
+
+ if (req->reset) {
+ rst_req.hdr.pcifunc = pcifunc;
+ return rvu_mbox_handler_nix_stats_rst(rvu, &rst_req, &rst_rsp);
+ }
+ rsp->rx.octs = RVU_LF_RX_STATS(RX_OCTS);
+ rsp->rx.ucast = RVU_LF_RX_STATS(RX_UCAST);
+ rsp->rx.bcast = RVU_LF_RX_STATS(RX_BCAST);
+ rsp->rx.mcast = RVU_LF_RX_STATS(RX_MCAST);
+ rsp->rx.drop = RVU_LF_RX_STATS(RX_DROP);
+ rsp->rx.err = RVU_LF_RX_STATS(RX_ERR);
+ rsp->rx.drop_octs = RVU_LF_RX_STATS(RX_DROP_OCTS);
+ rsp->rx.drop_mcast = RVU_LF_RX_STATS(RX_DRP_MCAST);
+ rsp->rx.drop_bcast = RVU_LF_RX_STATS(RX_DRP_BCAST);
+
+ rsp->tx.octs = RVU_LF_TX_STATS(TX_OCTS);
+ rsp->tx.ucast = RVU_LF_TX_STATS(TX_UCAST);
+ rsp->tx.bcast = RVU_LF_TX_STATS(TX_BCAST);
+ rsp->tx.mcast = RVU_LF_TX_STATS(TX_MCAST);
+ rsp->tx.drop = RVU_LF_TX_STATS(TX_DROP);
+
+ rsp->pcifunc = req->pcifunc;
+ return 0;
+}
+
static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
{
int id;
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index 1329617f8d6f..3a6a85ae47e5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -28,6 +28,67 @@ MODULE_DESCRIPTION(DRV_STRING);
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);

+static void rvu_rep_get_stats(struct work_struct *work)
+{
+ struct delayed_work *del_work = to_delayed_work(work);
+ struct nix_stats_req *req;
+ struct nix_stats_rsp *rsp;
+ struct rep_stats *stats;
+ struct otx2_nic *priv;
+ struct rep_dev *rep;
+ int err;
+
+ rep = container_of(del_work, struct rep_dev, stats_wrk);
+ priv = rep->mdev;
+
+ mutex_lock(&priv->mbox.lock);
+ req = otx2_mbox_alloc_msg_nix_lf_stats(&priv->mbox);
+ if (!req) {
+ mutex_unlock(&priv->mbox.lock);
+ return;
+ }
+ req->pcifunc = rep->pcifunc;
+ err = otx2_sync_mbox_msg_busy_poll(&priv->mbox);
+ if (err)
+ goto exit;
+
+ rsp = (struct nix_stats_rsp *)
+ otx2_mbox_get_rsp(&priv->mbox.mbox, 0, &req->hdr);
+
+ if (IS_ERR(rsp)) {
+ err = PTR_ERR(rsp);
+ goto exit;
+ }
+
+ stats = &rep->stats;
+ stats->rx_bytes = rsp->rx.octs;
+ stats->rx_frames = rsp->rx.ucast + rsp->rx.bcast +
+ rsp->rx.mcast;
+ stats->rx_drops = rsp->rx.drop;
+ stats->rx_mcast_frames = rsp->rx.mcast;
+ stats->tx_bytes = rsp->tx.octs;
+ stats->tx_frames = rsp->tx.ucast + rsp->tx.bcast + rsp->tx.mcast;
+ stats->tx_drops = rsp->tx.drop;
+exit:
+ mutex_unlock(&priv->mbox.lock);
+}
+
+static void rvu_rep_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
+{
+ struct rep_dev *rep = netdev_priv(dev);
+
+ stats->rx_packets = rep->stats.rx_frames;
+ stats->rx_bytes = rep->stats.rx_bytes;
+ stats->rx_dropped = rep->stats.rx_drops;
+ stats->multicast = rep->stats.rx_mcast_frames;
+
+ stats->tx_packets = rep->stats.tx_frames;
+ stats->tx_bytes = rep->stats.tx_bytes;
+ stats->tx_dropped = rep->stats.tx_drops;
+
+ schedule_delayed_work(&rep->stats_wrk, msecs_to_jiffies(100));
+}
+
static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
{
struct esw_cfg_req *req;
@@ -87,6 +148,7 @@ static const struct net_device_ops rvu_rep_netdev_ops = {
.ndo_open = rvu_rep_open,
.ndo_stop = rvu_rep_stop,
.ndo_start_xmit = rvu_rep_xmit,
+ .ndo_get_stats64 = rvu_rep_get_stats64,
};

static int rvu_rep_napi_init(struct otx2_nic *priv)
@@ -234,6 +296,8 @@ int rvu_rep_create(struct otx2_nic *priv)
ndev->netdev_ops = NULL;
goto exit;
}
+
+ INIT_DELAYED_WORK(&rep->stats_wrk, rvu_rep_get_stats);
}
err = rvu_rep_napi_init(priv);
if (err)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
index be6c939e5cba..9526b886b173 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
@@ -17,9 +17,23 @@
#define PCI_DEVID_RVU_REP 0xA0E0

#define RVU_MAX_REP OTX2_MAX_CQ_CNT
+
+struct rep_stats {
+ u64 rx_bytes;
+ u64 rx_frames;
+ u64 rx_drops;
+ u64 rx_mcast_frames;
+
+ u64 tx_bytes;
+ u64 tx_frames;
+ u64 tx_drops;
+};
+
struct rep_dev {
struct otx2_nic *mdev;
struct net_device *netdev;
+ struct rep_stats stats;
+ struct delayed_work stats_wrk;
u16 rep_id;
u16 pcifunc;
};
--
2.25.1


2024-04-16 05:09:40

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 9/9] octeontx2-pf: Add representors for sdp MAC

Current silicons support 2 types of MACs, SDP and
RPM MAC. This patch adds representors for SDP MAC
interfaces.

Signed-off-by: Geetha sowjanya <[email protected]>
---
.../ethernet/marvell/octeontx2/nic/cn10k.c | 4 +-
.../ethernet/marvell/octeontx2/nic/cn10k.h | 2 +-
.../marvell/octeontx2/nic/otx2_common.c | 47 ++++++++++++++-----
.../marvell/octeontx2/nic/otx2_common.h | 26 +++++++---
.../ethernet/marvell/octeontx2/nic/otx2_pf.c | 13 +++--
.../ethernet/marvell/octeontx2/nic/otx2_reg.h | 1 +
.../ethernet/marvell/octeontx2/nic/otx2_vf.c | 11 ++++-
7 files changed, 79 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
index c1c99d7054f8..777e123e69c7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
@@ -72,7 +72,7 @@ int cn10k_lmtst_init(struct otx2_nic *pfvf)
}
EXPORT_SYMBOL(cn10k_lmtst_init);

-int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
+int cn10k_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura)
{
struct nix_cn10k_aq_enq_req *aq;
struct otx2_nic *pfvf = dev;
@@ -88,7 +88,7 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
aq->sq.ena = 1;
aq->sq.smq = otx2_get_smq_idx(pfvf, qidx);
aq->sq.smq_rr_weight = mtu_to_dwrr_weight(pfvf, pfvf->tx_max_pktlen);
- aq->sq.default_chan = pfvf->hw.tx_chan_base;
+ aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset;
aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */
aq->sq.sqb_aura = sqb_aura;
aq->sq.sq_int_ena = NIX_SQINT_BITS;
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h
index c1861f7de254..e3f0bce9908f 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h
@@ -26,7 +26,7 @@ static inline int mtu_to_dwrr_weight(struct otx2_nic *pfvf, int mtu)

int cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx);
-int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
+int cn10k_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
int cn10k_lmtst_init(struct otx2_nic *pfvf);
int cn10k_free_all_ipolicers(struct otx2_nic *pfvf);
int cn10k_alloc_matchall_ipolicer(struct otx2_nic *pfvf);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 4b53af087cb4..f0f0d18ab302 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -253,7 +253,7 @@ int otx2_config_pause_frm(struct otx2_nic *pfvf)
struct cgx_pause_frm_cfg *req;
int err;

- if (is_otx2_lbkvf(pfvf->pdev))
+ if (is_otx2_lbkvf(pfvf->pdev) || is_otx2_sdp_rep(pfvf->pdev))
return 0;

mutex_lock(&pfvf->mbox.lock);
@@ -647,12 +647,21 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool txschq_for
req->reg[2] = NIX_AF_MDQX_SCHEDULE(schq);
req->regval[2] = dwrr_val;
} else if (lvl == NIX_TXSCH_LVL_TL4) {
+ int sdp_chan = hw->tx_chan_base + prio;
+
+ if (is_otx2_sdp_rep(pfvf->pdev))
+ prio = 0;
parent = schq_list[NIX_TXSCH_LVL_TL3][prio];
req->reg[0] = NIX_AF_TL4X_PARENT(schq);
req->regval[0] = parent << 16;
req->num_regs++;
req->reg[1] = NIX_AF_TL4X_SCHEDULE(schq);
req->regval[1] = dwrr_val;
+ if (is_otx2_sdp_rep(pfvf->pdev)) {
+ req->num_regs++;
+ req->reg[2] = NIX_AF_TL4X_SDP_LINK_CFG(schq);
+ req->regval[2] = BIT_ULL(12) | BIT_ULL(13) | (sdp_chan & 0xff);
+ }
} else if (lvl == NIX_TXSCH_LVL_TL3) {
parent = schq_list[NIX_TXSCH_LVL_TL2][prio];
req->reg[0] = NIX_AF_TL3X_PARENT(schq);
@@ -660,7 +669,7 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool txschq_for
req->num_regs++;
req->reg[1] = NIX_AF_TL3X_SCHEDULE(schq);
req->regval[1] = dwrr_val;
- if (lvl == hw->txschq_link_cfg_lvl) {
+ if (lvl == hw->txschq_link_cfg_lvl && !is_otx2_sdp_rep(pfvf->pdev)) {
req->num_regs++;
req->reg[2] = NIX_AF_TL3_TL2X_LINKX_CFG(schq, hw->tx_link);
/* Enable this queue and backpressure
@@ -677,7 +686,7 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool txschq_for
req->reg[1] = NIX_AF_TL2X_SCHEDULE(schq);
req->regval[1] = TXSCH_TL1_DFLT_RR_PRIO << 24 | dwrr_val;

- if (lvl == hw->txschq_link_cfg_lvl) {
+ if (lvl == hw->txschq_link_cfg_lvl && !is_otx2_sdp_rep(pfvf->pdev)) {
req->num_regs++;
req->reg[2] = NIX_AF_TL3_TL2X_LINKX_CFG(schq, hw->tx_link);
/* Enable this queue and backpressure
@@ -736,6 +745,7 @@ EXPORT_SYMBOL(otx2_smq_flush);

int otx2_txsch_alloc(struct otx2_nic *pfvf)
{
+ int chan_cnt = pfvf->hw.tx_chan_cnt;
struct nix_txsch_alloc_req *req;
struct nix_txsch_alloc_rsp *rsp;
int lvl, schq, rc;
@@ -748,6 +758,12 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)
/* Request one schq per level */
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++)
req->schq[lvl] = 1;
+
+ if (is_otx2_sdp_rep(pfvf->pdev) && chan_cnt > 1) {
+ req->schq[NIX_TXSCH_LVL_SMQ] = chan_cnt;
+ req->schq[NIX_TXSCH_LVL_TL4] = chan_cnt;
+ }
+
rc = otx2_sync_mbox_msg(&pfvf->mbox);
if (rc)
return rc;
@@ -758,10 +774,12 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)
return PTR_ERR(rsp);

/* Setup transmit scheduler list */
- for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++)
+ for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
+ pfvf->hw.txschq_cnt[lvl] = rsp->schq[lvl];
for (schq = 0; schq < rsp->schq[lvl]; schq++)
pfvf->hw.txschq_list[lvl][schq] =
rsp->schq_list[lvl][schq];
+ }

pfvf->hw.txschq_link_cfg_lvl = rsp->link_cfg_lvl;
pfvf->hw.txschq_aggr_lvl_rr_prio = rsp->aggr_lvl_rr_prio;
@@ -799,12 +817,15 @@ EXPORT_SYMBOL(otx2_txschq_free_one);

void otx2_txschq_stop(struct otx2_nic *pfvf)
{
- int lvl, schq;
+ int lvl, schq, idx;

/* free non QOS TLx nodes */
- for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++)
- otx2_txschq_free_one(pfvf, lvl,
- pfvf->hw.txschq_list[lvl][0]);
+ for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
+ for (idx = 0; idx < pfvf->hw.txschq_cnt[lvl]; idx++) {
+ otx2_txschq_free_one(pfvf, lvl,
+ pfvf->hw.txschq_list[lvl][idx]);
+ }
+ }

/* Clear the txschq list */
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
@@ -884,7 +905,7 @@ static int otx2_rq_init(struct otx2_nic *pfvf, u16 qidx, u16 lpb_aura)
return otx2_sync_mbox_msg(&pfvf->mbox);
}

-int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
+int otx2_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura)
{
struct otx2_nic *pfvf = dev;
struct otx2_snd_queue *sq;
@@ -903,7 +924,7 @@ int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
aq->sq.ena = 1;
aq->sq.smq = otx2_get_smq_idx(pfvf, qidx);
aq->sq.smq_rr_quantum = mtu_to_dwrr_weight(pfvf, pfvf->tx_max_pktlen);
- aq->sq.default_chan = pfvf->hw.tx_chan_base;
+ aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset;
aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */
aq->sq.sqb_aura = sqb_aura;
aq->sq.sq_int_ena = NIX_SQINT_BITS;
@@ -926,6 +947,7 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
struct otx2_qset *qset = &pfvf->qset;
struct otx2_snd_queue *sq;
struct otx2_pool *pool;
+ u8 chan_offset;
int err;

pool = &pfvf->qset.pool[sqb_aura];
@@ -972,7 +994,8 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
sq->stats.bytes = 0;
sq->stats.pkts = 0;

- err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
+ chan_offset = qidx % pfvf->hw.tx_chan_cnt;
+ err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, chan_offset, sqb_aura);
if (err) {
kfree(sq->sg);
sq->sg = NULL;
@@ -1739,6 +1762,8 @@ void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf,
pfvf->hw.sqb_size = rsp->sqb_size;
pfvf->hw.rx_chan_base = rsp->rx_chan_base;
pfvf->hw.tx_chan_base = rsp->tx_chan_base;
+ pfvf->hw.rx_chan_cnt = rsp->rx_chan_cnt;
+ pfvf->hw.tx_chan_cnt = rsp->tx_chan_cnt;
pfvf->hw.lso_tsov4_idx = rsp->lso_tsov4_idx;
pfvf->hw.lso_tsov6_idx = rsp->lso_tsov6_idx;
pfvf->hw.cgx_links = rsp->cgx_links;
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
index 865d5d3146a9..1d6939786495 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
@@ -42,6 +42,8 @@
#define PCI_SUBSYS_DEVID_96XX_RVU_PFVF 0xB200
#define PCI_SUBSYS_DEVID_CN10K_B_RVU_PFVF 0xBD00

+#define PCI_DEVID_OCTEONTX2_SDP_REP 0xA0F7
+
/* PCI BAR nos */
#define PCI_CFG_REG_BAR_NUM 2
#define PCI_MBOX_BAR_NUM 4
@@ -198,6 +200,7 @@ struct otx2_hw {

/* NIX */
u8 txschq_link_cfg_lvl;
+ u8 txschq_cnt[NIX_TXSCH_LVL_CNT];
u8 txschq_aggr_lvl_rr_prio;
u16 txschq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
u16 matchall_ipolicer;
@@ -208,6 +211,8 @@ struct otx2_hw {
/* HW settings, coalescing etc */
u16 rx_chan_base;
u16 tx_chan_base;
+ u8 rx_chan_cnt;
+ u8 tx_chan_cnt;
u16 cq_qcount_wait;
u16 cq_ecount_wait;
u16 rq_skid;
@@ -343,7 +348,7 @@ struct otx2_flow_config {
};

struct dev_hw_ops {
- int (*sq_aq_init)(void *dev, u16 qidx, u16 sqb_aura);
+ int (*sq_aq_init)(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
void (*sqe_flush)(void *dev, struct otx2_snd_queue *sq,
int size, int qidx);
int (*refill_pool_ptrs)(void *dev, struct otx2_cq_queue *cq);
@@ -536,6 +541,11 @@ static inline bool is_96xx_B0(struct pci_dev *pdev)
(pdev->subsystem_device == PCI_SUBSYS_DEVID_96XX_RVU_PFVF);
}

+static inline bool is_otx2_sdp_rep(struct pci_dev *pdev)
+{
+ return pdev->device == PCI_DEVID_OCTEONTX2_SDP_REP;
+}
+
/* REVID for PCIe devices.
* Bits 0..1: minor pass, bit 3..2: major pass
* bits 7..4: midr id
@@ -898,15 +908,19 @@ static inline void otx2_dma_unmap_page(struct otx2_nic *pfvf,
static inline u16 otx2_get_smq_idx(struct otx2_nic *pfvf, u16 qidx)
{
u16 smq;
+ int idx;
+
#ifdef CONFIG_DCB
if (qidx < NIX_PF_PFC_PRIO_MAX && pfvf->pfc_alloc_status[qidx])
return pfvf->pfc_schq_list[NIX_TXSCH_LVL_SMQ][qidx];
#endif
/* check if qidx falls under QOS queues */
- if (qidx >= pfvf->hw.non_qos_queues)
+ if (qidx >= pfvf->hw.non_qos_queues) {
smq = pfvf->qos.qid_to_sqmap[qidx - pfvf->hw.non_qos_queues];
- else
- smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][0];
+ } else {
+ idx = qidx % pfvf->hw.txschq_cnt[NIX_TXSCH_LVL_SMQ];
+ smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][idx];
+ }

return smq;
}
@@ -973,8 +987,8 @@ int otx2_nix_config_bp(struct otx2_nic *pfvf, bool enable);
void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, int qidx);
void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);
int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura);
-int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
-int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
+int otx2_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
+int cn10k_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq,
dma_addr_t *dma);
int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 8fc26a95a871..b46ea92a1ba5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -1593,10 +1593,15 @@ int otx2_init_hw_resources(struct otx2_nic *pf)
}

for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
- err = otx2_txschq_config(pf, lvl, 0, false);
- if (err) {
- mutex_unlock(&mbox->lock);
- goto err_free_nix_queues;
+ int idx;
+
+ for (idx = 0; idx < pf->hw.txschq_cnt[lvl]; idx++) {
+ err = otx2_txschq_config(pf, lvl, idx, false);
+ if (err) {
+ dev_err(pf->dev, "Failed to config TXSCH\n");
+ mutex_unlock(&mbox->lock);
+ goto err_free_nix_queues;
+ }
}
}

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h
index 45a32e4b49d1..defcb9ea21e1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h
@@ -140,6 +140,7 @@

/* NIX AF transmit scheduler registers */
#define NIX_AF_SMQX_CFG(a) (0x700 | (a) << 16)
+#define NIX_AF_TL4X_SDP_LINK_CFG(a) (0xB10 | (a) << 16)
#define NIX_AF_TL1X_SCHEDULE(a) (0xC00 | (a) << 16)
#define NIX_AF_TL1X_CIR(a) (0xC20 | (a) << 16)
#define NIX_AF_TL1X_TOPOLOGY(a) (0xC80 | (a) << 16)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
index 048f9a744542..fd093c4c3289 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
@@ -21,6 +21,7 @@
static const struct pci_device_id otx2_vf_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_AFVF) },
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_VF) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_SDP_REP) },
{ }
};

@@ -371,7 +372,7 @@ static int otx2vf_open(struct net_device *netdev)

/* LBKs do not receive link events so tell everyone we are up here */
vf = netdev_priv(netdev);
- if (is_otx2_lbkvf(vf->pdev)) {
+ if (is_otx2_lbkvf(vf->pdev) || is_otx2_sdp_rep(vf->pdev)) {
pr_info("%s NIC Link is UP\n", netdev->name);
netif_carrier_on(netdev);
netif_tx_start_all_queues(netdev);
@@ -683,6 +684,14 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
snprintf(netdev->name, sizeof(netdev->name), "lbk%d", n);
}

+ if (is_otx2_sdp_rep(vf->pdev)) {
+ int n;
+
+ n = (vf->pcifunc >> RVU_PFVF_FUNC_SHIFT) & RVU_PFVF_FUNC_MASK;
+ n -= 1;
+ snprintf(netdev->name, sizeof(netdev->name), "sdp%d-%d", pdev->bus->number, n);
+ }
+
err = register_netdev(netdev);
if (err) {
dev_err(dev, "Failed to register netdevice\n");
--
2.25.1


2024-04-16 05:10:12

by Geetha sowjanya

[permalink] [raw]
Subject: [net-next PATCH 8/9] octeontx2-pf: Configure VF mtu via representor

Add support to manage the mtu configuration for VF through representor.
On update of representor mtu a mbox notification is send
to VF to update its mtu.

Signed-off-by: Sai Krishna <[email protected]>
Signed-off-by: Geetha sowjanya <[email protected]>
---
.../ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 +++++
.../net/ethernet/marvell/octeontx2/nic/rep.c | 17 +++++++++++++++++
2 files changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 2a1bc8cdea19..8fc26a95a871 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -854,6 +854,11 @@ static int otx2_mbox_up_handler_rep_event_up_notify(struct otx2_nic *pf,
{
struct net_device *netdev = pf->netdev;

+ if (info->event == RVU_EVENT_MTU_CHANGE) {
+ netdev->mtu = info->evt_data.mtu;
+ return 0;
+ }
+
if (info->event == RVU_EVENT_PORT_STATE) {
if (info->evt_data.port_state) {
pf->flags |= OTX2_FLAG_PORT_UP;
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index 2677a229a9e7..a2941e3d16be 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -79,6 +79,22 @@ int rvu_event_up_notify(struct otx2_nic *pf, struct rep_event *info)
return 0;
}

+static int rvu_rep_change_mtu(struct net_device *dev, int new_mtu)
+{
+ struct rep_dev *rep = netdev_priv(dev);
+ struct otx2_nic *priv = rep->mdev;
+ struct rep_event evt = {0};
+
+ netdev_info(dev, "Changing MTU from %d to %d\n",
+ dev->mtu, new_mtu);
+ dev->mtu = new_mtu;
+
+ evt.evt_data.mtu = new_mtu;
+ evt.pcifunc = rep->pcifunc;
+ rvu_rep_notify_pfvf(priv, RVU_EVENT_MTU_CHANGE, &evt);
+ return 0;
+}
+
static void rvu_rep_get_stats(struct work_struct *work)
{
struct delayed_work *del_work = to_delayed_work(work);
@@ -225,6 +241,7 @@ static const struct net_device_ops rvu_rep_netdev_ops = {
.ndo_stop = rvu_rep_stop,
.ndo_start_xmit = rvu_rep_xmit,
.ndo_get_stats64 = rvu_rep_get_stats64,
+ .ndo_change_mtu = rvu_rep_change_mtu,
};

static int rvu_rep_napi_init(struct otx2_nic *priv)
--
2.25.1


2024-04-17 00:32:40

by kernel test robot

[permalink] [raw]
Subject: Re: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

Hi Geetha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url: https://github.com/intel-lab-lkp/linux/commits/Geetha-sowjanya/octeontx2-pf-Refactoring-RVU-driver/20240416-131052
base: net-next/main
patch link: https://lore.kernel.org/r/20240416050616.6056-4-gakula%40marvell.com
patch subject: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20240417/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240417/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/net/ethernet/marvell/octeontx2/nic/rep.c: In function 'rvu_rep_create':
>> drivers/net/ethernet/marvell/octeontx2/nic/rep.c:163:66: warning: '%d' directive output may be truncated writing between 1 and 4 bytes into a region of size between 1 and 11 [-Wformat-truncation=]
163 | snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
| ^~
drivers/net/ethernet/marvell/octeontx2/nic/rep.c:163:58: note: directive argument in the range [0, 1023]
163 | snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
| ^~~~~~~~~~~
drivers/net/ethernet/marvell/octeontx2/nic/rep.c:163:17: note: 'snprintf' output between 7 and 20 bytes into a destination of size 16
163 | snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164 | rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +163 drivers/net/ethernet/marvell/octeontx2/nic/rep.c

131
132 int rvu_rep_create(struct otx2_nic *priv)
133 {
134 int rep_cnt = priv->rep_cnt;
135 struct net_device *ndev;
136 struct rep_dev *rep;
137 int rep_id, err;
138 u16 pcifunc;
139
140 priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
141 if (!priv->reps)
142 return -ENOMEM;
143
144 for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
145 ndev = alloc_etherdev(sizeof(*rep));
146 if (!ndev) {
147 dev_err(priv->dev, "PFVF representor:%d creation failed\n", rep_id);
148 err = -ENOMEM;
149 goto exit;
150 }
151
152 rep = netdev_priv(ndev);
153 priv->reps[rep_id] = rep;
154 rep->mdev = priv;
155 rep->netdev = ndev;
156 rep->rep_id = rep_id;
157
158 ndev->min_mtu = OTX2_MIN_MTU;
159 ndev->max_mtu = priv->hw.max_mtu;
160 pcifunc = priv->rep_pf_map[rep_id];
161 rep->pcifunc = pcifunc;
162
> 163 snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
164 rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
165
166 eth_hw_addr_random(ndev);
167 if (register_netdev(ndev)) {
168 dev_err(priv->dev, "PFVF reprentator registration failed\n");
169 free_netdev(ndev);
170 ndev->netdev_ops = NULL;
171 goto exit;
172 }
173 }
174 err = rvu_rep_napi_init(priv);
175 if (err)
176 goto exit;
177
178 return 0;
179 exit:
180 rvu_rep_free_netdev(priv);
181 return err;
182 }
183

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-04-17 01:25:36

by kernel test robot

[permalink] [raw]
Subject: Re: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

Hi Geetha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url: https://github.com/intel-lab-lkp/linux/commits/Geetha-sowjanya/octeontx2-pf-Refactoring-RVU-driver/20240416-131052
base: net-next/main
patch link: https://lore.kernel.org/r/20240416050616.6056-4-gakula%40marvell.com
patch subject: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240417/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240417/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/marvell/octeontx2/nic/rep.c:167:7: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
167 | if (register_netdev(ndev)) {
| ^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/marvell/octeontx2/nic/rep.c:181:9: note: uninitialized use occurs here
181 | return err;
| ^~~
drivers/net/ethernet/marvell/octeontx2/nic/rep.c:167:3: note: remove the 'if' if its condition is always false
167 | if (register_netdev(ndev)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
168 | dev_err(priv->dev, "PFVF reprentator registration failed\n");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169 | free_netdev(ndev);
| ~~~~~~~~~~~~~~~~~~
170 | ndev->netdev_ops = NULL;
| ~~~~~~~~~~~~~~~~~~~~~~~~
171 | goto exit;
| ~~~~~~~~~~
172 | }
| ~
drivers/net/ethernet/marvell/octeontx2/nic/rep.c:137:17: note: initialize the variable 'err' to silence this warning
137 | int rep_id, err;
| ^
| = 0
1 warning generated.


vim +167 drivers/net/ethernet/marvell/octeontx2/nic/rep.c

131
132 int rvu_rep_create(struct otx2_nic *priv)
133 {
134 int rep_cnt = priv->rep_cnt;
135 struct net_device *ndev;
136 struct rep_dev *rep;
137 int rep_id, err;
138 u16 pcifunc;
139
140 priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
141 if (!priv->reps)
142 return -ENOMEM;
143
144 for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
145 ndev = alloc_etherdev(sizeof(*rep));
146 if (!ndev) {
147 dev_err(priv->dev, "PFVF representor:%d creation failed\n", rep_id);
148 err = -ENOMEM;
149 goto exit;
150 }
151
152 rep = netdev_priv(ndev);
153 priv->reps[rep_id] = rep;
154 rep->mdev = priv;
155 rep->netdev = ndev;
156 rep->rep_id = rep_id;
157
158 ndev->min_mtu = OTX2_MIN_MTU;
159 ndev->max_mtu = priv->hw.max_mtu;
160 pcifunc = priv->rep_pf_map[rep_id];
161 rep->pcifunc = pcifunc;
162
163 snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
164 rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
165
166 eth_hw_addr_random(ndev);
> 167 if (register_netdev(ndev)) {
168 dev_err(priv->dev, "PFVF reprentator registration failed\n");
169 free_netdev(ndev);
170 ndev->netdev_ops = NULL;
171 goto exit;
172 }
173 }
174 err = rvu_rep_napi_init(priv);
175 if (err)
176 goto exit;
177
178 return 0;
179 exit:
180 rvu_rep_free_netdev(priv);
181 return err;
182 }
183

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-04-17 04:10:51

by Kalesh Anakkur Purayil

[permalink] [raw]
Subject: Re: [net-next PATCH 5/9] octeontx2-af: Add packet path between representor and VF

On Tue, Apr 16, 2024 at 10:38 AM Geetha sowjanya <[email protected]> wrote:
>
> This patch installs tcam rules to stree traffic representors
> and VF when swicthdev mode is set. To support this a HW loopback
> channel is reserved. Through this channel packet are routed
> between representor and VFs. "ESW_CFG" mbox is defined to
> notify AF for installing rules.
>
> Signed-off-by: Geetha sowjanya <[email protected]>
> ---
> .../net/ethernet/marvell/octeontx2/af/mbox.h | 7 +
> .../net/ethernet/marvell/octeontx2/af/rvu.h | 7 +-
> .../marvell/octeontx2/af/rvu_devlink.c | 6 +
> .../ethernet/marvell/octeontx2/af/rvu_nix.c | 7 +-
> .../ethernet/marvell/octeontx2/af/rvu_rep.c | 241 +++++++++++++++++-
> .../marvell/octeontx2/af/rvu_switch.c | 18 +-
> .../net/ethernet/marvell/octeontx2/nic/rep.c | 19 ++
> 7 files changed, 297 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> index c77c02730cf9..3b36da28a8f4 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> @@ -144,6 +144,7 @@ M(LMTST_TBL_SETUP, 0x00a, lmtst_tbl_setup, lmtst_tbl_setup_req, \
> M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
> M(PTP_GET_CAP, 0x00c, ptp_get_cap, msg_req, ptp_get_cap_rsp) \
> M(GET_REP_CNT, 0x00d, get_rep_cnt, msg_req, get_rep_cnt_rsp) \
> +M(ESW_CFG, 0x00e, esw_cfg, esw_cfg_req, msg_rsp) \
> /* CGX mbox IDs (range 0x200 - 0x3FF) */ \
> M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
> M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
> @@ -1532,6 +1533,12 @@ struct get_rep_cnt_rsp {
> u64 rsvd;
> };
>
> +struct esw_cfg_req {
> + struct mbox_msghdr hdr;
> + u8 ena;
> + u64 rsvd;
> +};
> +
> struct flow_msg {
> unsigned char dmac[6];
> unsigned char smac[6];
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> index 1d76d52d7a5d..c8572d79a968 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> @@ -596,6 +596,7 @@ struct rvu {
> u16 rep_pcifunc;
> int rep_cnt;
> u16 *rep2pfvf_map;
> + u8 rep_mode;
> };
>
> static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
> @@ -1025,7 +1026,7 @@ int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr);
> /* RVU Switch */
> void rvu_switch_enable(struct rvu *rvu);
> void rvu_switch_disable(struct rvu *rvu);
> -void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc);
> +void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
> void rvu_switch_enable_lbk_link(struct rvu *rvu, u16 pcifunc, bool ena);
>
> int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir,
> @@ -1039,4 +1040,8 @@ int rvu_mcs_flr_handler(struct rvu *rvu, u16 pcifunc);
> void rvu_mcs_ptp_cfg(struct rvu *rvu, u8 rpm_id, u8 lmac_id, bool ena);
> void rvu_mcs_exit(struct rvu *rvu);
>
> +/* Representor APIs */
> +int rvu_rep_pf_init(struct rvu *rvu);
> +int rvu_rep_install_mcam_rules(struct rvu *rvu);
> +void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
> #endif /* RVU_H */
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> index 96c04f7d93f8..8a3b7fb61883 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> @@ -1464,6 +1464,9 @@ static int rvu_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
> struct rvu *rvu = rvu_dl->rvu;
> struct rvu_switch *rswitch;
>
> + if (rvu->rep_mode)
> + return -EOPNOTSUPP;
> +
> rswitch = &rvu->rswitch;
> *mode = rswitch->mode;
>
> @@ -1477,6 +1480,9 @@ static int rvu_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
> struct rvu *rvu = rvu_dl->rvu;
> struct rvu_switch *rswitch;
>
> + if (rvu->rep_mode)
> + return -EOPNOTSUPP;
> +
> rswitch = &rvu->rswitch;
> switch (mode) {
> case DEVLINK_ESWITCH_MODE_LEGACY:
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> index 4ef5bb7b337f..75d5c1bc00e1 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> @@ -2738,7 +2738,7 @@ void rvu_nix_tx_tl2_cfg(struct rvu *rvu, int blkaddr, u16 pcifunc,
> int schq;
> u64 cfg;
>
> - if (!is_pf_cgxmapped(rvu, pf))
> + if (!is_pf_cgxmapped(rvu, pf) && !is_rep_dev(rvu, pcifunc))
> return;
>
> cfg = enable ? (BIT_ULL(12) | RVU_SWITCH_LBK_CHAN) : 0;
> @@ -4368,8 +4368,6 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
> if (test_bit(PF_SET_VF_TRUSTED, &pfvf->flags) && from_vf)
> ether_addr_copy(pfvf->default_mac, req->mac_addr);
>
> - rvu_switch_update_rules(rvu, pcifunc);
> -
> return 0;
> }
>
> @@ -5159,7 +5157,7 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
> pfvf = rvu_get_pfvf(rvu, pcifunc);
> set_bit(NIXLF_INITIALIZED, &pfvf->flags);
>
> - rvu_switch_update_rules(rvu, pcifunc);
> + rvu_switch_update_rules(rvu, pcifunc, true);
>
> return rvu_cgx_start_stop_io(rvu, pcifunc, true);
> }
> @@ -5187,6 +5185,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
> if (err)
> return err;
>
> + rvu_switch_update_rules(rvu, pcifunc, false);
> rvu_cgx_tx_enable(rvu, pcifunc, true);
>
> return 0;
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> index d07cb356d3d6..5c015e8dfbbe 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> @@ -13,6 +13,246 @@
> #include "rvu.h"
> #include "rvu_reg.h"
>
> +static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
> +{
> + int id;
> +
> + for (id = 0; id < rvu->rep_cnt; id++)
> + if (rvu->rep2pfvf_map[id] == pcifunc)
> + return id;
> + return -ENODEV;
> +}
> +
> +static int rvu_rep_tx_vlan_cfg(struct rvu *rvu, u16 pcifunc,
> + u16 vlan_tci, int *vidx)
> +{
> + struct nix_vtag_config req = {0};
> + struct nix_vtag_config_rsp rsp = {0};
> + u64 etype = ETH_P_8021Q;
> + int err;
> +
> + /* Insert vlan tag */
> + req.hdr.pcifunc = pcifunc;
> + req.vtag_size = VTAGSIZE_T4;
> + req.cfg_type = 0; /* tx vlan cfg */
> + req.tx.cfg_vtag0 = true;
> + req.tx.vtag0 = etype << 48 | ntohs(vlan_tci);
> +
> + err = rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
> + if (err) {
> + dev_err(rvu->dev, "Tx vlan config failed\n");
> + return err;
> + }
> + *vidx = rsp.vtag0_idx;
> + return 0;
> +}
> +
> +static int rvu_rep_rx_vlan_cfg(struct rvu *rvu, u16 pcifunc)
> +{
> + struct nix_vtag_config req = {0};
> + struct nix_vtag_config_rsp rsp;
> +
> + /* config strip, capture and size */
> + req.hdr.pcifunc = pcifunc;
> + req.vtag_size = VTAGSIZE_T4;
> + req.cfg_type = 1; /* rx vlan cfg */
> + req.rx.vtag_type = NIX_AF_LFX_RX_VTAG_TYPE0;
> + req.rx.strip_vtag = true;
> + req.rx.capture_vtag = false;
> +
> + return rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
> +}
> +
> +static int rvu_rep_install_rx_rule(struct rvu *rvu, u16 pcifunc,
> + u16 entry, bool rte)
> +{
> + struct npc_install_flow_req req = { 0 };
> + struct npc_install_flow_rsp rsp = { 0 };
> + struct rvu_pfvf *pfvf;
> + u16 vlan_tci, rep_id;
> +
> + pfvf = rvu_get_pfvf(rvu, pcifunc);
> +
> + /* To stree the traffic from Representee to Representor */
> + rep_id = (u16)rvu_rep_get_vlan_id(rvu, pcifunc);
> + if (rte) {
> + vlan_tci = rep_id | 0x1ull << 8;
> + req.vf = rvu->rep_pcifunc;
> + req.op = NIX_RX_ACTIONOP_UCAST;
> + req.index = rep_id;
> + } else {
> + vlan_tci = rep_id;
> + req.vf = pcifunc;
> + req.op = NIX_RX_ACTION_DEFAULT;
> + }
> +
> + rvu_rep_rx_vlan_cfg(rvu, req.vf);
> + req.entry = entry;
> + req.hdr.pcifunc = 0; /* AF is requester */
> + req.features = BIT_ULL(NPC_OUTER_VID) | BIT_ULL(NPC_VLAN_ETYPE_CTAG);
> + req.vtag0_valid = true;
> + req.vtag0_type = NIX_AF_LFX_RX_VTAG_TYPE0;
> + req.packet.vlan_etype = ETH_P_8021Q;
> + req.mask.vlan_etype = ETH_P_8021Q;
> + req.packet.vlan_tci = vlan_tci;
> + req.mask.vlan_tci = 0xffff;
> +
> + req.channel = RVU_SWITCH_LBK_CHAN;
> + req.chan_mask = 0xffff;
> + req.intf = pfvf->nix_rx_intf;
> +
> + return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
> +}
> +
> +static int rvu_rep_install_tx_rule(struct rvu *rvu, u16 pcifunc, u16 entry,
> + bool rte)
> +{
> + struct npc_install_flow_req req = { 0 };
> + struct npc_install_flow_rsp rsp = { 0 };
> + struct rvu_pfvf *pfvf;
> + int vidx, err;
> + u16 vlan_tci;
> + u8 lbkid;
> +
> + pfvf = rvu_get_pfvf(rvu, pcifunc);
> + vlan_tci = rvu_rep_get_vlan_id(rvu, pcifunc);
> + if (rte)
> + vlan_tci |= 0x1ull << 8;
> +
> + err = rvu_rep_tx_vlan_cfg(rvu, pcifunc, vlan_tci, &vidx);
> + if (err)
> + return err;
> +
> + lbkid = pfvf->nix_blkaddr == BLKADDR_NIX0 ? 0 : 1;
> + req.hdr.pcifunc = 0; /* AF is requester */
> + if (rte) {
> + req.vf = pcifunc;
> + } else {
> + req.vf = rvu->rep_pcifunc;
> + req.packet.sq_id = vlan_tci;
> + req.mask.sq_id = 0xffff;
> + }
> +
> + req.entry = entry;
> + req.intf = pfvf->nix_tx_intf;
> + req.op = NIX_TX_ACTIONOP_UCAST_CHAN;
> + req.index = (lbkid << 8) | RVU_SWITCH_LBK_CHAN;
> + req.set_cntr = 1;
> + req.vtag0_def = vidx;
> + req.vtag0_op = 1;
> + return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
> +}
> +
> +int rvu_rep_install_mcam_rules(struct rvu *rvu)
> +{
> + struct rvu_switch *rswitch = &rvu->rswitch;
> + u16 start = rswitch->start_entry;
> + struct rvu_hwinfo *hw = rvu->hw;
> + u16 pcifunc, entry = 0;
> + int pf, vf, numvfs;
> + int err, nixlf, i;
> + u8 rep;
> +
> + for (pf = 1; pf < hw->total_pfs; pf++) {
> + if (!is_pf_cgxmapped(rvu, pf))
> + continue;
> +
> + pcifunc = pf << RVU_PFVF_PF_SHIFT;
> + rvu_get_nix_blkaddr(rvu, pcifunc);
> + rep = true;
> + for (i = 0; i < 2; i++) {
> + err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
> + if (err)
> + return err;
> + rswitch->entry2pcifunc[entry++] = pcifunc;
> +
> + err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
> + if (err)
> + return err;
> + rswitch->entry2pcifunc[entry++] = pcifunc;
> + rep = false;
> + }
> +
> + rvu_get_pf_numvfs(rvu, pf, &numvfs, NULL);
> + for (vf = 0; vf < numvfs; vf++) {
> + pcifunc = pf << RVU_PFVF_PF_SHIFT |
> + ((vf + 1) & RVU_PFVF_FUNC_MASK);
> + rvu_get_nix_blkaddr(rvu, pcifunc);
> +
> + /* Skip installimg rules if nixlf is not attached */
> + err = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
> + if (err)
> + continue;
> + rep = true;
> + for (i = 0; i < 2; i++) {
> + err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
> + if (err)
> + return err;
> + rswitch->entry2pcifunc[entry++] = pcifunc;
> +
> + err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
> + if (err)
> + return err;
> + rswitch->entry2pcifunc[entry++] = pcifunc;
> + rep = false;
> + }
> + }
> + }
> + return 0;
> +}
> +
> +void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
> +{
> + struct rvu_switch *rswitch = &rvu->rswitch;
> + struct npc_mcam *mcam = &rvu->hw->mcam;
> + u32 max = rswitch->used_entries;
> + int blkaddr;
> + u16 entry;
> +
> + if (!rswitch->used_entries)
> + return;
> +
> + blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
> +
> + if (blkaddr < 0)
> + return;
> +
> + rvu_switch_enable_lbk_link(rvu, pcifunc, ena);
> + mutex_lock(&mcam->lock);
> + for (entry = 0; entry < max; entry++) {
> + if (rswitch->entry2pcifunc[entry] == pcifunc)
> + npc_enable_mcam_entry(rvu, mcam, blkaddr, entry, ena);
> + }
> + mutex_unlock(&mcam->lock);
> +}
> +
> +int rvu_rep_pf_init(struct rvu *rvu)
> +{
> + u16 pcifunc = rvu->rep_pcifunc;
> + struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
> +
> + set_bit(NIXLF_INITIALIZED, &pfvf->flags);
> + rvu_switch_enable_lbk_link(rvu, pcifunc, true);
> + rvu_rep_rx_vlan_cfg(rvu, pcifunc);
> + return 0;
> +}
> +
> +int rvu_mbox_handler_esw_cfg(struct rvu *rvu, struct esw_cfg_req *req,
> + struct msg_rsp *rsp)
> +{
> + if (req->hdr.pcifunc != rvu->rep_pcifunc)
> + return 0;
> +
> + rvu->rep_mode = req->ena;
> +
> + if (req->ena)
> + rvu_switch_enable(rvu);
> + else
> + rvu_switch_disable(rvu);
> +
> + return 0;
> +}
> +
> int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
> struct get_rep_cnt_rsp *rsp)
> {
> @@ -45,4 +285,3 @@ int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
> }
> return 0;
> }
> -
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> index ceb81eebf65e..268efb7c1c15 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> @@ -166,6 +166,8 @@ void rvu_switch_enable(struct rvu *rvu)
>
> alloc_req.contig = true;
> alloc_req.count = rvu->cgx_mapped_pfs + rvu->cgx_mapped_vfs;
> + if (rvu->rep_mode)
> + alloc_req.count = alloc_req.count * 4;
> ret = rvu_mbox_handler_npc_mcam_alloc_entry(rvu, &alloc_req,
> &alloc_rsp);
> if (ret) {
> @@ -189,7 +191,12 @@ void rvu_switch_enable(struct rvu *rvu)
> rswitch->used_entries = alloc_rsp.count;
> rswitch->start_entry = alloc_rsp.entry;
>
> - ret = rvu_switch_install_rules(rvu);
> + if (rvu->rep_mode) {
> + rvu_rep_pf_init(rvu);
> + ret = rvu_rep_install_mcam_rules(rvu);
> + } else {
> + ret = rvu_switch_install_rules(rvu);
> + }
> if (ret)
> goto uninstall_rules;
>
> @@ -222,6 +229,9 @@ void rvu_switch_disable(struct rvu *rvu)
> if (!rswitch->used_entries)
> return;
>
> + if (rvu->rep_mode)
> + goto free_ents;
> +
> for (pf = 1; pf < hw->total_pfs; pf++) {
> if (!is_pf_cgxmapped(rvu, pf))
> continue;
> @@ -249,6 +259,7 @@ void rvu_switch_disable(struct rvu *rvu)
> }
> }
>
> +free_ents:
> uninstall_req.start = rswitch->start_entry;
> uninstall_req.end = rswitch->start_entry + rswitch->used_entries - 1;
> free_req.all = 1;
> @@ -258,12 +269,15 @@ void rvu_switch_disable(struct rvu *rvu)
> kfree(rswitch->entry2pcifunc);
> }
>
> -void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc)
> +void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
> {
> struct rvu_switch *rswitch = &rvu->rswitch;
> u32 max = rswitch->used_entries;
> u16 entry;
>
> + if (rvu->rep_mode)
> + return rvu_rep_update_rules(rvu, pcifunc, ena);
> +
> if (!rswitch->used_entries)
> return;
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> index 187b00156bcd..1329617f8d6f 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> @@ -28,6 +28,22 @@ MODULE_DESCRIPTION(DRV_STRING);
> MODULE_LICENSE("GPL");
> MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
>
> +static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
> +{
> + struct esw_cfg_req *req;
> +
> + mutex_lock(&priv->mbox.lock);
> + req = otx2_mbox_alloc_msg_esw_cfg(&priv->mbox);
> + if (!req) {
> + mutex_unlock(&priv->mbox.lock);
> + return -ENOMEM;
> + }
> + req->ena = ena;
> + otx2_sync_mbox_msg(&priv->mbox);
> + mutex_unlock(&priv->mbox.lock);
> + return 0;
> +}
> +
> static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device *dev)
> {
> struct rep_dev *rep = netdev_priv(dev);
> @@ -170,6 +186,8 @@ static void rvu_rep_free_netdev(struct otx2_nic *priv)
>
> void rvu_rep_destroy(struct otx2_nic *priv)
> {
> + /* Remove mcam rules */
> + rvu_eswitch_config(priv, false);
> rvu_rep_free_cq_rsrc(priv);
> rvu_rep_free_netdev(priv);
> }
> @@ -221,6 +239,7 @@ int rvu_rep_create(struct otx2_nic *priv)
> if (err)
> goto exit;
>
> + rvu_eswitch_config(priv, true);
> return 0;
> exit:
> rvu_rep_free_netdev(priv);
> --
> 2.25.1
>
>


--
Regards,
Kalesh A P


Attachments:
smime.p7s (4.14 kB)
S/MIME Cryptographic Signature

2024-04-17 05:31:47

by Kalesh Anakkur Purayil

[permalink] [raw]
Subject: Re: [net-next PATCH 5/9] octeontx2-af: Add packet path between representor and VF

On Wed, Apr 17, 2024 at 9:40 AM Kalesh Anakkur Purayil
<[email protected]> wrote:
>
> On Tue, Apr 16, 2024 at 10:38 AM Geetha sowjanya <[email protected]> wrote:
> >
> > This patch installs tcam rules to stree traffic representors
> > and VF when swicthdev mode is set. To support this a HW loopback
> > channel is reserved. Through this channel packet are routed
> > between representor and VFs. "ESW_CFG" mbox is defined to
> > notify AF for installing rules.
> >
> > Signed-off-by: Geetha sowjanya <[email protected]>
> > ---
> > .../net/ethernet/marvell/octeontx2/af/mbox.h | 7 +
> > .../net/ethernet/marvell/octeontx2/af/rvu.h | 7 +-
> > .../marvell/octeontx2/af/rvu_devlink.c | 6 +
> > .../ethernet/marvell/octeontx2/af/rvu_nix.c | 7 +-
> > .../ethernet/marvell/octeontx2/af/rvu_rep.c | 241 +++++++++++++++++-
> > .../marvell/octeontx2/af/rvu_switch.c | 18 +-
> > .../net/ethernet/marvell/octeontx2/nic/rep.c | 19 ++
> > 7 files changed, 297 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> > index c77c02730cf9..3b36da28a8f4 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> > @@ -144,6 +144,7 @@ M(LMTST_TBL_SETUP, 0x00a, lmtst_tbl_setup, lmtst_tbl_setup_req, \
> > M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
> > M(PTP_GET_CAP, 0x00c, ptp_get_cap, msg_req, ptp_get_cap_rsp) \
> > M(GET_REP_CNT, 0x00d, get_rep_cnt, msg_req, get_rep_cnt_rsp) \
> > +M(ESW_CFG, 0x00e, esw_cfg, esw_cfg_req, msg_rsp) \
> > /* CGX mbox IDs (range 0x200 - 0x3FF) */ \
> > M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
> > M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
> > @@ -1532,6 +1533,12 @@ struct get_rep_cnt_rsp {
> > u64 rsvd;
> > };
> >
> > +struct esw_cfg_req {
> > + struct mbox_msghdr hdr;
> > + u8 ena;
> > + u64 rsvd;
> > +};
> > +
> > struct flow_msg {
> > unsigned char dmac[6];
> > unsigned char smac[6];
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > index 1d76d52d7a5d..c8572d79a968 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > @@ -596,6 +596,7 @@ struct rvu {
> > u16 rep_pcifunc;
> > int rep_cnt;
> > u16 *rep2pfvf_map;
> > + u8 rep_mode;
> > };
> >
> > static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
> > @@ -1025,7 +1026,7 @@ int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr);
> > /* RVU Switch */
> > void rvu_switch_enable(struct rvu *rvu);
> > void rvu_switch_disable(struct rvu *rvu);
> > -void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc);
> > +void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
> > void rvu_switch_enable_lbk_link(struct rvu *rvu, u16 pcifunc, bool ena);
> >
> > int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir,
> > @@ -1039,4 +1040,8 @@ int rvu_mcs_flr_handler(struct rvu *rvu, u16 pcifunc);
> > void rvu_mcs_ptp_cfg(struct rvu *rvu, u8 rpm_id, u8 lmac_id, bool ena);
> > void rvu_mcs_exit(struct rvu *rvu);
> >
> > +/* Representor APIs */
> > +int rvu_rep_pf_init(struct rvu *rvu);
> > +int rvu_rep_install_mcam_rules(struct rvu *rvu);
> > +void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
> > #endif /* RVU_H */
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> > index 96c04f7d93f8..8a3b7fb61883 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> > @@ -1464,6 +1464,9 @@ static int rvu_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
> > struct rvu *rvu = rvu_dl->rvu;
> > struct rvu_switch *rswitch;
> >
> > + if (rvu->rep_mode)
> > + return -EOPNOTSUPP;
> > +
> > rswitch = &rvu->rswitch;
> > *mode = rswitch->mode;
> >
> > @@ -1477,6 +1480,9 @@ static int rvu_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
> > struct rvu *rvu = rvu_dl->rvu;
> > struct rvu_switch *rswitch;
> >
> > + if (rvu->rep_mode)
> > + return -EOPNOTSUPP;
> > +
> > rswitch = &rvu->rswitch;
> > switch (mode) {
> > case DEVLINK_ESWITCH_MODE_LEGACY:
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> > index 4ef5bb7b337f..75d5c1bc00e1 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> > @@ -2738,7 +2738,7 @@ void rvu_nix_tx_tl2_cfg(struct rvu *rvu, int blkaddr, u16 pcifunc,
> > int schq;
> > u64 cfg;
> >
> > - if (!is_pf_cgxmapped(rvu, pf))
> > + if (!is_pf_cgxmapped(rvu, pf) && !is_rep_dev(rvu, pcifunc))
> > return;
> >
> > cfg = enable ? (BIT_ULL(12) | RVU_SWITCH_LBK_CHAN) : 0;
> > @@ -4368,8 +4368,6 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
> > if (test_bit(PF_SET_VF_TRUSTED, &pfvf->flags) && from_vf)
> > ether_addr_copy(pfvf->default_mac, req->mac_addr);
> >
> > - rvu_switch_update_rules(rvu, pcifunc);
> > -
> > return 0;
> > }
> >
> > @@ -5159,7 +5157,7 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
> > pfvf = rvu_get_pfvf(rvu, pcifunc);
> > set_bit(NIXLF_INITIALIZED, &pfvf->flags);
> >
> > - rvu_switch_update_rules(rvu, pcifunc);
> > + rvu_switch_update_rules(rvu, pcifunc, true);
> >
> > return rvu_cgx_start_stop_io(rvu, pcifunc, true);
> > }
> > @@ -5187,6 +5185,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
> > if (err)
> > return err;
> >
> > + rvu_switch_update_rules(rvu, pcifunc, false);
> > rvu_cgx_tx_enable(rvu, pcifunc, true);
> >
> > return 0;
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> > index d07cb356d3d6..5c015e8dfbbe 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> > @@ -13,6 +13,246 @@
> > #include "rvu.h"
> > #include "rvu_reg.h"
> >
> > +static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
> > +{
> > + int id;
> > +
> > + for (id = 0; id < rvu->rep_cnt; id++)
> > + if (rvu->rep2pfvf_map[id] == pcifunc)
> > + return id;
> > + return -ENODEV;
> > +}
> > +
> > +static int rvu_rep_tx_vlan_cfg(struct rvu *rvu, u16 pcifunc,
> > + u16 vlan_tci, int *vidx)
> > +{
> > + struct nix_vtag_config req = {0};
> > + struct nix_vtag_config_rsp rsp = {0};
[Kalesh] RCT order. Also I think {0} is not needed and you can just use {}
> > + u64 etype = ETH_P_8021Q;
> > + int err;
> > +
> > + /* Insert vlan tag */
> > + req.hdr.pcifunc = pcifunc;
> > + req.vtag_size = VTAGSIZE_T4;
> > + req.cfg_type = 0; /* tx vlan cfg */
> > + req.tx.cfg_vtag0 = true;
> > + req.tx.vtag0 = etype << 48 | ntohs(vlan_tci);
> > +
> > + err = rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
> > + if (err) {
> > + dev_err(rvu->dev, "Tx vlan config failed\n");
> > + return err;
> > + }
> > + *vidx = rsp.vtag0_idx;
> > + return 0;
> > +}
> > +
> > +static int rvu_rep_rx_vlan_cfg(struct rvu *rvu, u16 pcifunc)
> > +{
> > + struct nix_vtag_config req = {0};
> > + struct nix_vtag_config_rsp rsp;
> > +
> > + /* config strip, capture and size */
> > + req.hdr.pcifunc = pcifunc;
> > + req.vtag_size = VTAGSIZE_T4;
> > + req.cfg_type = 1; /* rx vlan cfg */
> > + req.rx.vtag_type = NIX_AF_LFX_RX_VTAG_TYPE0;
> > + req.rx.strip_vtag = true;
> > + req.rx.capture_vtag = false;
> > +
> > + return rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
> > +}
> > +
> > +static int rvu_rep_install_rx_rule(struct rvu *rvu, u16 pcifunc,
> > + u16 entry, bool rte)
> > +{
> > + struct npc_install_flow_req req = { 0 };
> > + struct npc_install_flow_rsp rsp = { 0 };
> > + struct rvu_pfvf *pfvf;
> > + u16 vlan_tci, rep_id;
> > +
> > + pfvf = rvu_get_pfvf(rvu, pcifunc);
> > +
> > + /* To stree the traffic from Representee to Representor */
[Kalesh] Typo. did you mean steer?
> > + rep_id = (u16)rvu_rep_get_vlan_id(rvu, pcifunc);
> > + if (rte) {
> > + vlan_tci = rep_id | 0x1ull << 8;
> > + req.vf = rvu->rep_pcifunc;
> > + req.op = NIX_RX_ACTIONOP_UCAST;
> > + req.index = rep_id;
> > + } else {
> > + vlan_tci = rep_id;
> > + req.vf = pcifunc;
> > + req.op = NIX_RX_ACTION_DEFAULT;
> > + }
> > +
> > + rvu_rep_rx_vlan_cfg(rvu, req.vf);
> > + req.entry = entry;
> > + req.hdr.pcifunc = 0; /* AF is requester */
> > + req.features = BIT_ULL(NPC_OUTER_VID) | BIT_ULL(NPC_VLAN_ETYPE_CTAG);
> > + req.vtag0_valid = true;
> > + req.vtag0_type = NIX_AF_LFX_RX_VTAG_TYPE0;
> > + req.packet.vlan_etype = ETH_P_8021Q;
> > + req.mask.vlan_etype = ETH_P_8021Q;
> > + req.packet.vlan_tci = vlan_tci;
> > + req.mask.vlan_tci = 0xffff;
> > +
> > + req.channel = RVU_SWITCH_LBK_CHAN;
> > + req.chan_mask = 0xffff;
> > + req.intf = pfvf->nix_rx_intf;
> > +
> > + return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
> > +}
> > +
> > +static int rvu_rep_install_tx_rule(struct rvu *rvu, u16 pcifunc, u16 entry,
> > + bool rte)
> > +{
> > + struct npc_install_flow_req req = { 0 };
> > + struct npc_install_flow_rsp rsp = { 0 };
> > + struct rvu_pfvf *pfvf;
> > + int vidx, err;
> > + u16 vlan_tci;
> > + u8 lbkid;
> > +
> > + pfvf = rvu_get_pfvf(rvu, pcifunc);
> > + vlan_tci = rvu_rep_get_vlan_id(rvu, pcifunc);
> > + if (rte)
> > + vlan_tci |= 0x1ull << 8;
> > +
> > + err = rvu_rep_tx_vlan_cfg(rvu, pcifunc, vlan_tci, &vidx);
> > + if (err)
> > + return err;
> > +
> > + lbkid = pfvf->nix_blkaddr == BLKADDR_NIX0 ? 0 : 1;
> > + req.hdr.pcifunc = 0; /* AF is requester */
> > + if (rte) {
> > + req.vf = pcifunc;
> > + } else {
> > + req.vf = rvu->rep_pcifunc;
> > + req.packet.sq_id = vlan_tci;
> > + req.mask.sq_id = 0xffff;
> > + }
> > +
> > + req.entry = entry;
> > + req.intf = pfvf->nix_tx_intf;
> > + req.op = NIX_TX_ACTIONOP_UCAST_CHAN;
> > + req.index = (lbkid << 8) | RVU_SWITCH_LBK_CHAN;
> > + req.set_cntr = 1;
> > + req.vtag0_def = vidx;
> > + req.vtag0_op = 1;
> > + return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
> > +}
> > +
> > +int rvu_rep_install_mcam_rules(struct rvu *rvu)
> > +{
> > + struct rvu_switch *rswitch = &rvu->rswitch;
> > + u16 start = rswitch->start_entry;
> > + struct rvu_hwinfo *hw = rvu->hw;
> > + u16 pcifunc, entry = 0;
> > + int pf, vf, numvfs;
> > + int err, nixlf, i;
> > + u8 rep;
> > +
> > + for (pf = 1; pf < hw->total_pfs; pf++) {
> > + if (!is_pf_cgxmapped(rvu, pf))
> > + continue;
> > +
> > + pcifunc = pf << RVU_PFVF_PF_SHIFT;
> > + rvu_get_nix_blkaddr(rvu, pcifunc);
> > + rep = true;
> > + for (i = 0; i < 2; i++) {
> > + err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
> > + if (err)
> > + return err;
> > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > +
> > + err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
> > + if (err)
> > + return err;
> > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > + rep = false;
> > + }
> > +
> > + rvu_get_pf_numvfs(rvu, pf, &numvfs, NULL);
> > + for (vf = 0; vf < numvfs; vf++) {
> > + pcifunc = pf << RVU_PFVF_PF_SHIFT |
> > + ((vf + 1) & RVU_PFVF_FUNC_MASK);
> > + rvu_get_nix_blkaddr(rvu, pcifunc);
> > +
> > + /* Skip installimg rules if nixlf is not attached */
> > + err = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
> > + if (err)
> > + continue;
> > + rep = true;
> > + for (i = 0; i < 2; i++) {
> > + err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
> > + if (err)
> > + return err;
> > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > +
> > + err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
> > + if (err)
> > + return err;
> > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > + rep = false;
> > + }
> > + }
> > + }
> > + return 0;
> > +}
> > +
> > +void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
> > +{
> > + struct rvu_switch *rswitch = &rvu->rswitch;
> > + struct npc_mcam *mcam = &rvu->hw->mcam;
[Kalesh: maintain RCT order
> > + u32 max = rswitch->used_entries;
> > + int blkaddr;
> > + u16 entry;
> > +
> > + if (!rswitch->used_entries)
> > + return;
> > +
> > + blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
> > +
[Kalesh] No need of a blank line here
> > + if (blkaddr < 0)
> > + return;
> > +
> > + rvu_switch_enable_lbk_link(rvu, pcifunc, ena);
> > + mutex_lock(&mcam->lock);
> > + for (entry = 0; entry < max; entry++) {
> > + if (rswitch->entry2pcifunc[entry] == pcifunc)
> > + npc_enable_mcam_entry(rvu, mcam, blkaddr, entry, ena);
> > + }
> > + mutex_unlock(&mcam->lock);
> > +}
> > +
> > +int rvu_rep_pf_init(struct rvu *rvu)
> > +{
> > + u16 pcifunc = rvu->rep_pcifunc;
> > + struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
> > +
> > + set_bit(NIXLF_INITIALIZED, &pfvf->flags);
> > + rvu_switch_enable_lbk_link(rvu, pcifunc, true);
> > + rvu_rep_rx_vlan_cfg(rvu, pcifunc);
> > + return 0;
[Kalesh] This function returns 0 unconditionally, maybe you can change
it to void?
> > +}
> > +
> > +int rvu_mbox_handler_esw_cfg(struct rvu *rvu, struct esw_cfg_req *req,
> > + struct msg_rsp *rsp)
> > +{
> > + if (req->hdr.pcifunc != rvu->rep_pcifunc)
> > + return 0;
> > +
> > + rvu->rep_mode = req->ena;
> > +
> > + if (req->ena)
> > + rvu_switch_enable(rvu);
> > + else
> > + rvu_switch_disable(rvu);
> > +
> > + return 0;
[Kalesh] This function returns 0 unconditionally, maybe you can change
it to void?
> > +}
> > +
> > int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
> > struct get_rep_cnt_rsp *rsp)
> > {
> > @@ -45,4 +285,3 @@ int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
> > }
> > return 0;
> > }
> > -
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> > index ceb81eebf65e..268efb7c1c15 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> > @@ -166,6 +166,8 @@ void rvu_switch_enable(struct rvu *rvu)
> >
> > alloc_req.contig = true;
> > alloc_req.count = rvu->cgx_mapped_pfs + rvu->cgx_mapped_vfs;
> > + if (rvu->rep_mode)
> > + alloc_req.count = alloc_req.count * 4;
> > ret = rvu_mbox_handler_npc_mcam_alloc_entry(rvu, &alloc_req,
> > &alloc_rsp);
> > if (ret) {
> > @@ -189,7 +191,12 @@ void rvu_switch_enable(struct rvu *rvu)
> > rswitch->used_entries = alloc_rsp.count;
> > rswitch->start_entry = alloc_rsp.entry;
> >
> > - ret = rvu_switch_install_rules(rvu);
> > + if (rvu->rep_mode) {
> > + rvu_rep_pf_init(rvu);
> > + ret = rvu_rep_install_mcam_rules(rvu);
> > + } else {
> > + ret = rvu_switch_install_rules(rvu);
> > + }
> > if (ret)
> > goto uninstall_rules;
> >
> > @@ -222,6 +229,9 @@ void rvu_switch_disable(struct rvu *rvu)
> > if (!rswitch->used_entries)
> > return;
> >
> > + if (rvu->rep_mode)
> > + goto free_ents;
> > +
> > for (pf = 1; pf < hw->total_pfs; pf++) {
> > if (!is_pf_cgxmapped(rvu, pf))
> > continue;
> > @@ -249,6 +259,7 @@ void rvu_switch_disable(struct rvu *rvu)
> > }
> > }
> >
> > +free_ents:
> > uninstall_req.start = rswitch->start_entry;
> > uninstall_req.end = rswitch->start_entry + rswitch->used_entries - 1;
> > free_req.all = 1;
> > @@ -258,12 +269,15 @@ void rvu_switch_disable(struct rvu *rvu)
> > kfree(rswitch->entry2pcifunc);
> > }
> >
> > -void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc)
> > +void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
> > {
> > struct rvu_switch *rswitch = &rvu->rswitch;
> > u32 max = rswitch->used_entries;
> > u16 entry;
> >
> > + if (rvu->rep_mode)
> > + return rvu_rep_update_rules(rvu, pcifunc, ena);
> > +
> > if (!rswitch->used_entries)
> > return;
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > index 187b00156bcd..1329617f8d6f 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > @@ -28,6 +28,22 @@ MODULE_DESCRIPTION(DRV_STRING);
> > MODULE_LICENSE("GPL");
> > MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
> >
> > +static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
> > +{
> > + struct esw_cfg_req *req;
> > +
> > + mutex_lock(&priv->mbox.lock);
> > + req = otx2_mbox_alloc_msg_esw_cfg(&priv->mbox);
> > + if (!req) {
> > + mutex_unlock(&priv->mbox.lock);
> > + return -ENOMEM;
> > + }
> > + req->ena = ena;
> > + otx2_sync_mbox_msg(&priv->mbox);
> > + mutex_unlock(&priv->mbox.lock);
> > + return 0;
> > +}
> > +
> > static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device *dev)
> > {
> > struct rep_dev *rep = netdev_priv(dev);
> > @@ -170,6 +186,8 @@ static void rvu_rep_free_netdev(struct otx2_nic *priv)
> >
> > void rvu_rep_destroy(struct otx2_nic *priv)
> > {
> > + /* Remove mcam rules */
> > + rvu_eswitch_config(priv, false);
> > rvu_rep_free_cq_rsrc(priv);
> > rvu_rep_free_netdev(priv);
> > }
> > @@ -221,6 +239,7 @@ int rvu_rep_create(struct otx2_nic *priv)
> > if (err)
> > goto exit;
> >
> > + rvu_eswitch_config(priv, true);
> > return 0;
> > exit:
> > rvu_rep_free_netdev(priv);
> > --
> > 2.25.1
> >
> >
>
>
> --
> Regards,
> Kalesh A P



--
Regards,
Kalesh A P


Attachments:
smime.p7s (4.14 kB)
S/MIME Cryptographic Signature

2024-04-17 05:46:31

by Kalesh Anakkur Purayil

[permalink] [raw]
Subject: Re: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

On Tue, Apr 16, 2024 at 10:37 AM Geetha sowjanya <[email protected]> wrote:
>
> Adds initial devlink support to set/get the switchdev mode.
> Representor netdevs are created for each rvu devices when
> the switch mode is set to 'switchdev'. These netdevs are
> be used to control and configure VFs.
>
> Signed-off-by: Geetha sowjanya <[email protected]>
> ---
> .../marvell/octeontx2/nic/otx2_devlink.c | 48 ++++++
> .../net/ethernet/marvell/octeontx2/nic/rep.c | 159 ++++++++++++++++++
> .../net/ethernet/marvell/octeontx2/nic/rep.h | 2 +
> 3 files changed, 209 insertions(+)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> index 4e1130496573..f4f5f5d93c7e 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> @@ -76,7 +76,53 @@ static const struct devlink_param otx2_dl_params[] = {
> otx2_dl_mcam_count_validate),
> };
>
> +#ifdef CONFIG_RVU_ESWITCH
> +static int otx2_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
> +{
> + struct otx2_devlink *otx2_dl = devlink_priv(devlink);
> + struct otx2_nic *pfvf = otx2_dl->pfvf;
> +
> + if (!is_rep_dev(pfvf->pdev))
> + return -EOPNOTSUPP;
> +
> + *mode = pfvf->esw_mode;
> +
> + return 0;
> +}
> +
> +static int otx2_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
> + struct netlink_ext_ack *extack)
> +{
> + struct otx2_devlink *otx2_dl = devlink_priv(devlink);
> + struct otx2_nic *pfvf = otx2_dl->pfvf;
> +
> + if (!is_rep_dev(pfvf->pdev))
> + return -EOPNOTSUPP;
> +
> + if (pfvf->esw_mode == mode)
> + return 0;
> +
> + pfvf->esw_mode = mode;
[Kalesh] Move this assignment after the switch block. Else, you will
end up updating pfvf->esw_mode to an unsupported mode even though
drover returns error.
> + switch (mode) {
> + case DEVLINK_ESWITCH_MODE_LEGACY:
> + rvu_rep_destroy(pfvf);
> + break;
> + case DEVLINK_ESWITCH_MODE_SWITCHDEV:
> + rvu_rep_create(pfvf);
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +#endif
> +
> static const struct devlink_ops otx2_devlink_ops = {
> +#ifdef CONFIG_RVU_ESWITCH
> + .eswitch_mode_get = otx2_devlink_eswitch_mode_get,
> + .eswitch_mode_set = otx2_devlink_eswitch_mode_set,
> +#endif
> };
>
> int otx2_register_dl(struct otx2_nic *pfvf)
> @@ -112,6 +158,7 @@ int otx2_register_dl(struct otx2_nic *pfvf)
> devlink_free(dl);
> return err;
> }
> +EXPORT_SYMBOL(otx2_register_dl);
>
> void otx2_unregister_dl(struct otx2_nic *pfvf)
> {
> @@ -123,3 +170,4 @@ void otx2_unregister_dl(struct otx2_nic *pfvf)
> ARRAY_SIZE(otx2_dl_params));
> devlink_free(dl);
> }
> +EXPORT_SYMBOL(otx2_unregister_dl);
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> index b892a7fe3ddc..fd55ef40c934 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> @@ -28,6 +28,159 @@ MODULE_DESCRIPTION(DRV_STRING);
> MODULE_LICENSE("GPL");
> MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
>
> +static int rvu_rep_napi_init(struct otx2_nic *priv)
> +{
> + struct otx2_cq_poll *cq_poll = NULL;
> + struct otx2_qset *qset = &priv->qset;
> + struct otx2_hw *hw = &priv->hw;
> + int err = 0, qidx, vec;
> + char *irq_name;
> +
> + qset->napi = kcalloc(hw->cint_cnt, sizeof(*cq_poll), GFP_KERNEL);
> + if (!qset->napi)
> + return -ENOMEM;
> +
> + /* Register NAPI handler */
> + for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
> + cq_poll = &qset->napi[qidx];
> + cq_poll->cint_idx = qidx;
> + cq_poll->cq_ids[CQ_RX] =
> + (qidx < hw->rx_queues) ? qidx : CINT_INVALID_CQ;
> + cq_poll->cq_ids[CQ_TX] = (qidx < hw->tx_queues) ?
> + qidx + hw->rx_queues : CINT_INVALID_CQ;
> + cq_poll->cq_ids[CQ_XDP] = CINT_INVALID_CQ;
> + cq_poll->cq_ids[CQ_QOS] = CINT_INVALID_CQ;
> +
> + cq_poll->dev = (void *)priv;
> + netif_napi_add(priv->reps[qidx]->netdev, &cq_poll->napi,
> + otx2_napi_handler);
> + napi_enable(&cq_poll->napi);
> + }
> + /* Register CQ IRQ handlers */
> + vec = hw->nix_msixoff + NIX_LF_CINT_VEC_START;
> + for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
> + irq_name = &hw->irq_name[vec * NAME_SIZE];
> +
> + snprintf(irq_name, NAME_SIZE, "rep%d-rxtx-%d", qidx, qidx);
> +
> + err = request_irq(pci_irq_vector(priv->pdev, vec),
> + otx2_cq_intr_handler, 0, irq_name,
> + &qset->napi[qidx]);
> + if (err) {
> + dev_err(priv->dev,
> + "RVU REP IRQ registration failed for CQ%d\n", qidx);
> + goto err_free_cints;
> + }
> + vec++;
> +
> + /* Enable CQ IRQ */
> + otx2_write64(priv, NIX_LF_CINTX_INT(qidx), BIT_ULL(0));
> + otx2_write64(priv, NIX_LF_CINTX_ENA_W1S(qidx), BIT_ULL(0));
> + }
> + priv->flags &= ~OTX2_FLAG_INTF_DOWN;
> + return 0;
> +
> +err_free_cints:
> + otx2_free_cints(priv, qidx);
> + otx2_disable_napi(priv);
> + return err;
> +}
> +
> +static void rvu_rep_free_cq_rsrc(struct otx2_nic *priv)
> +{
> + struct otx2_cq_poll *cq_poll = NULL;
> + struct otx2_qset *qset = &priv->qset;
> + int qidx, vec;
> +
> + /* Cleanup CQ NAPI and IRQ */
> + vec = priv->hw.nix_msixoff + NIX_LF_CINT_VEC_START;
> + for (qidx = 0; qidx < priv->hw.cint_cnt; qidx++) {
> + /* Disable interrupt */
> + otx2_write64(priv, NIX_LF_CINTX_ENA_W1C(qidx), BIT_ULL(0));
> +
> + synchronize_irq(pci_irq_vector(priv->pdev, vec));
> +
> + cq_poll = &qset->napi[qidx];
> + napi_synchronize(&cq_poll->napi);
> + vec++;
> + }
> + otx2_free_cints(priv, priv->hw.cint_cnt);
> + otx2_disable_napi(priv);
> +}
> +
> +static void rvu_rep_free_netdev(struct otx2_nic *priv)
> +{
> + struct rep_dev *rep;
> + int rep_id;
> +
> + for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++) {
> + rep = priv->reps[rep_id];
> + if (rep && rep->netdev->netdev_ops) {
> + unregister_netdev(rep->netdev);
> + free_netdev(rep->netdev);
> + }
> + }
> + devm_kfree(priv->dev, priv->reps);
> +}
> +
> +void rvu_rep_destroy(struct otx2_nic *priv)
> +{
> + rvu_rep_free_cq_rsrc(priv);
> + rvu_rep_free_netdev(priv);
> +}
> +
> +int rvu_rep_create(struct otx2_nic *priv)
> +{
> + int rep_cnt = priv->rep_cnt;
> + struct net_device *ndev;
> + struct rep_dev *rep;
> + int rep_id, err;
> + u16 pcifunc;
> +
> + priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
> + if (!priv->reps)
> + return -ENOMEM;
> +
> + for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
> + ndev = alloc_etherdev(sizeof(*rep));
> + if (!ndev) {
> + dev_err(priv->dev, "PFVF representor:%d creation failed\n", rep_id);
> + err = -ENOMEM;
> + goto exit;
> + }
> +
> + rep = netdev_priv(ndev);
> + priv->reps[rep_id] = rep;
> + rep->mdev = priv;
> + rep->netdev = ndev;
> + rep->rep_id = rep_id;
> +
> + ndev->min_mtu = OTX2_MIN_MTU;
> + ndev->max_mtu = priv->hw.max_mtu;
> + pcifunc = priv->rep_pf_map[rep_id];
> + rep->pcifunc = pcifunc;
> +
> + snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
> + rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
> +
> + eth_hw_addr_random(ndev);
> + if (register_netdev(ndev)) {
> + dev_err(priv->dev, "PFVF reprentator registration failed\n");
> + free_netdev(ndev);
> + ndev->netdev_ops = NULL;
[Kalesh] update "rc" with the return status of register_netdev()
> + goto exit;
> + }
> + }
> + err = rvu_rep_napi_init(priv);
> + if (err)
> + goto exit;
> +
> + return 0;
> +exit:
> + rvu_rep_free_netdev(priv);
> + return err;
> +}
> +
> static int rvu_rep_rsrc_free(struct otx2_nic *priv)
> {
> struct otx2_qset *qset = &priv->qset;
> @@ -162,6 +315,10 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> if (err)
> goto err_detach_rsrc;
>
> + err = otx2_register_dl(priv);
> + if (err)
> + goto err_detach_rsrc;
> +
> return 0;
>
> err_detach_rsrc:
> @@ -183,6 +340,8 @@ static void rvu_rep_remove(struct pci_dev *pdev)
> {
> struct otx2_nic *priv = pci_get_drvdata(pdev);
>
> + otx2_unregister_dl(priv);
> + rvu_rep_destroy(priv);
> rvu_rep_rsrc_free(priv);
> otx2_detach_resources(&priv->mbox);
> if (priv->hw.lmt_info)
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> index 30cce17eb48b..be6c939e5cba 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> @@ -29,4 +29,6 @@ static inline bool is_rep_dev(struct pci_dev *pdev)
> return pdev->device == PCI_DEVID_RVU_REP;
> }
>
> +int rvu_rep_create(struct otx2_nic *priv);
> +void rvu_rep_destroy(struct otx2_nic *priv);
> #endif /* REP_H */
> --
> 2.25.1
>
>


--
Regards,
Kalesh A P


Attachments:
smime.p7s (4.14 kB)
S/MIME Cryptographic Signature

2024-04-17 13:46:07

by Geetha sowjanya

[permalink] [raw]
Subject: RE: [EXTERNAL] Re: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

Hi Kalesh,



> -----Original Message-----
> From: Kalesh Anakkur Purayil <[email protected]>
> Sent: Wednesday, April 17, 2024 9:58 AM
> To: Geethasowjanya Akula <[email protected]>
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; Sunil
> Kovvuri Goutham <[email protected]>; Subbaraya Sundeep Bhatta
> <[email protected]>; Hariprasad Kelam <[email protected]>
> Subject: [EXTERNAL] Re: [net-next PATCH 3/9] octeontx2-pf: Create
> representor netdev
> ----------------------------------------------------------------------
> On Tue, Apr 16, 2024 at 10:37 AM Geetha sowjanya <[email protected]>
> wrote:
> >
> > Adds initial devlink support to set/get the switchdev mode.
> > Representor netdevs are created for each rvu devices when
> > the switch mode is set to 'switchdev'. These netdevs are
> > be used to control and configure VFs.
> >
> > Signed-off-by: Geetha sowjanya <[email protected]>
> > ---
> > .../marvell/octeontx2/nic/otx2_devlink.c | 48 ++++++
> > .../net/ethernet/marvell/octeontx2/nic/rep.c | 159 ++++++++++++++++++
> > .../net/ethernet/marvell/octeontx2/nic/rep.h | 2 +
> > 3 files changed, 209 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> > index 4e1130496573..f4f5f5d93c7e 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
> > @@ -76,7 +76,53 @@ static const struct devlink_param otx2_dl_params[] =
> {
> > otx2_dl_mcam_count_validate),
> > };
> >
> > +#ifdef CONFIG_RVU_ESWITCH
> > +static int otx2_devlink_eswitch_mode_get(struct devlink *devlink, u16
> *mode)
> > +{
> > + struct otx2_devlink *otx2_dl = devlink_priv(devlink);
> > + struct otx2_nic *pfvf = otx2_dl->pfvf;
> > +
> > + if (!is_rep_dev(pfvf->pdev))
> > + return -EOPNOTSUPP;
> > +
> > + *mode = pfvf->esw_mode;
> > +
> > + return 0;
> > +}
> > +
> > +static int otx2_devlink_eswitch_mode_set(struct devlink *devlink, u16
> mode,
> > + struct netlink_ext_ack *extack)
> > +{
> > + struct otx2_devlink *otx2_dl = devlink_priv(devlink);
> > + struct otx2_nic *pfvf = otx2_dl->pfvf;
> > +
> > + if (!is_rep_dev(pfvf->pdev))
> > + return -EOPNOTSUPP;
> > +
> > + if (pfvf->esw_mode == mode)
> > + return 0;
> > +
> > + pfvf->esw_mode = mode;
> [Kalesh] Move this assignment after the switch block. Else, you will
> end up updating pfvf->esw_mode to an unsupported mode even though
> drover returns error.
Ack.
> > + switch (mode) {
> > + case DEVLINK_ESWITCH_MODE_LEGACY:
> > + rvu_rep_destroy(pfvf);
> > + break;
> > + case DEVLINK_ESWITCH_MODE_SWITCHDEV:
> > + rvu_rep_create(pfvf);
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
> > +
> > + return 0;
> > +}
> > +#endif
> > +
> > static const struct devlink_ops otx2_devlink_ops = {
> > +#ifdef CONFIG_RVU_ESWITCH
> > + .eswitch_mode_get = otx2_devlink_eswitch_mode_get,
> > + .eswitch_mode_set = otx2_devlink_eswitch_mode_set,
> > +#endif
> > };
> >
> > int otx2_register_dl(struct otx2_nic *pfvf)
> > @@ -112,6 +158,7 @@ int otx2_register_dl(struct otx2_nic *pfvf)
> > devlink_free(dl);
> > return err;
> > }
> > +EXPORT_SYMBOL(otx2_register_dl);
> >
> > void otx2_unregister_dl(struct otx2_nic *pfvf)
> > {
> > @@ -123,3 +170,4 @@ void otx2_unregister_dl(struct otx2_nic *pfvf)
> > ARRAY_SIZE(otx2_dl_params));
> > devlink_free(dl);
> > }
> > +EXPORT_SYMBOL(otx2_unregister_dl);
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > index b892a7fe3ddc..fd55ef40c934 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > @@ -28,6 +28,159 @@ MODULE_DESCRIPTION(DRV_STRING);
> > MODULE_LICENSE("GPL");
> > MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
> >
> > +static int rvu_rep_napi_init(struct otx2_nic *priv)
> > +{
> > + struct otx2_cq_poll *cq_poll = NULL;
> > + struct otx2_qset *qset = &priv->qset;
> > + struct otx2_hw *hw = &priv->hw;
> > + int err = 0, qidx, vec;
> > + char *irq_name;
> > +
> > + qset->napi = kcalloc(hw->cint_cnt, sizeof(*cq_poll), GFP_KERNEL);
> > + if (!qset->napi)
> > + return -ENOMEM;
> > +
> > + /* Register NAPI handler */
> > + for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
> > + cq_poll = &qset->napi[qidx];
> > + cq_poll->cint_idx = qidx;
> > + cq_poll->cq_ids[CQ_RX] =
> > + (qidx < hw->rx_queues) ? qidx : CINT_INVALID_CQ;
> > + cq_poll->cq_ids[CQ_TX] = (qidx < hw->tx_queues) ?
> > + qidx + hw->rx_queues : CINT_INVALID_CQ;
> > + cq_poll->cq_ids[CQ_XDP] = CINT_INVALID_CQ;
> > + cq_poll->cq_ids[CQ_QOS] = CINT_INVALID_CQ;
> > +
> > + cq_poll->dev = (void *)priv;
> > + netif_napi_add(priv->reps[qidx]->netdev, &cq_poll->napi,
> > + otx2_napi_handler);
> > + napi_enable(&cq_poll->napi);
> > + }
> > + /* Register CQ IRQ handlers */
> > + vec = hw->nix_msixoff + NIX_LF_CINT_VEC_START;
> > + for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
> > + irq_name = &hw->irq_name[vec * NAME_SIZE];
> > +
> > + snprintf(irq_name, NAME_SIZE, "rep%d-rxtx-%d", qidx, qidx);
> > +
> > + err = request_irq(pci_irq_vector(priv->pdev, vec),
> > + otx2_cq_intr_handler, 0, irq_name,
> > + &qset->napi[qidx]);
> > + if (err) {
> > + dev_err(priv->dev,
> > + "RVU REP IRQ registration failed for CQ%d\n", qidx);
> > + goto err_free_cints;
> > + }
> > + vec++;
> > +
> > + /* Enable CQ IRQ */
> > + otx2_write64(priv, NIX_LF_CINTX_INT(qidx), BIT_ULL(0));
> > + otx2_write64(priv, NIX_LF_CINTX_ENA_W1S(qidx), BIT_ULL(0));
> > + }
> > + priv->flags &= ~OTX2_FLAG_INTF_DOWN;
> > + return 0;
> > +
> > +err_free_cints:
> > + otx2_free_cints(priv, qidx);
> > + otx2_disable_napi(priv);
> > + return err;
> > +}
> > +
> > +static void rvu_rep_free_cq_rsrc(struct otx2_nic *priv)
> > +{
> > + struct otx2_cq_poll *cq_poll = NULL;
> > + struct otx2_qset *qset = &priv->qset;
> > + int qidx, vec;
> > +
> > + /* Cleanup CQ NAPI and IRQ */
> > + vec = priv->hw.nix_msixoff + NIX_LF_CINT_VEC_START;
> > + for (qidx = 0; qidx < priv->hw.cint_cnt; qidx++) {
> > + /* Disable interrupt */
> > + otx2_write64(priv, NIX_LF_CINTX_ENA_W1C(qidx), BIT_ULL(0));
> > +
> > + synchronize_irq(pci_irq_vector(priv->pdev, vec));
> > +
> > + cq_poll = &qset->napi[qidx];
> > + napi_synchronize(&cq_poll->napi);
> > + vec++;
> > + }
> > + otx2_free_cints(priv, priv->hw.cint_cnt);
> > + otx2_disable_napi(priv);
> > +}
> > +
> > +static void rvu_rep_free_netdev(struct otx2_nic *priv)
> > +{
> > + struct rep_dev *rep;
> > + int rep_id;
> > +
> > + for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++) {
> > + rep = priv->reps[rep_id];
> > + if (rep && rep->netdev->netdev_ops) {
> > + unregister_netdev(rep->netdev);
> > + free_netdev(rep->netdev);
> > + }
> > + }
> > + devm_kfree(priv->dev, priv->reps);
> > +}
> > +
> > +void rvu_rep_destroy(struct otx2_nic *priv)
> > +{
> > + rvu_rep_free_cq_rsrc(priv);
> > + rvu_rep_free_netdev(priv);
> > +}
> > +
> > +int rvu_rep_create(struct otx2_nic *priv)
> > +{
> > + int rep_cnt = priv->rep_cnt;
> > + struct net_device *ndev;
> > + struct rep_dev *rep;
> > + int rep_id, err;
> > + u16 pcifunc;
> > +
> > + priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev),
> GFP_KERNEL);
> > + if (!priv->reps)
> > + return -ENOMEM;
> > +
> > + for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
> > + ndev = alloc_etherdev(sizeof(*rep));
> > + if (!ndev) {
> > + dev_err(priv->dev, "PFVF representor:%d creation failed\n",
> rep_id);
> > + err = -ENOMEM;
> > + goto exit;
> > + }
> > +
> > + rep = netdev_priv(ndev);
> > + priv->reps[rep_id] = rep;
> > + rep->mdev = priv;
> > + rep->netdev = ndev;
> > + rep->rep_id = rep_id;
> > +
> > + ndev->min_mtu = OTX2_MIN_MTU;
> > + ndev->max_mtu = priv->hw.max_mtu;
> > + pcifunc = priv->rep_pf_map[rep_id];
> > + rep->pcifunc = pcifunc;
> > +
> > + snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
> > + rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
> > +
> > + eth_hw_addr_random(ndev);
> > + if (register_netdev(ndev)) {
> > + dev_err(priv->dev, "PFVF reprentator registration failed\n");
> > + free_netdev(ndev);
> > + ndev->netdev_ops = NULL;
> [Kalesh] update "rc" with the return status of register_netdev()
Ack. Thanks for reviewing. Will submit the v2 with the changes.
> > + goto exit;
> > + }
> > + }
> > + err = rvu_rep_napi_init(priv);
> > + if (err)
> > + goto exit;
> > +
> > + return 0;
> > +exit:
> > + rvu_rep_free_netdev(priv);
> > + return err;
> > +}
> > +
> > static int rvu_rep_rsrc_free(struct otx2_nic *priv)
> > {
> > struct otx2_qset *qset = &priv->qset;
> > @@ -162,6 +315,10 @@ static int rvu_rep_probe(struct pci_dev *pdev,
> const struct pci_device_id *id)
> > if (err)
> > goto err_detach_rsrc;
> >
> > + err = otx2_register_dl(priv);
> > + if (err)
> > + goto err_detach_rsrc;
> > +
> > return 0;
> >
> > err_detach_rsrc:
> > @@ -183,6 +340,8 @@ static void rvu_rep_remove(struct pci_dev *pdev)
> > {
> > struct otx2_nic *priv = pci_get_drvdata(pdev);
> >
> > + otx2_unregister_dl(priv);
> > + rvu_rep_destroy(priv);
> > rvu_rep_rsrc_free(priv);
> > otx2_detach_resources(&priv->mbox);
> > if (priv->hw.lmt_info)
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> > index 30cce17eb48b..be6c939e5cba 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
> > @@ -29,4 +29,6 @@ static inline bool is_rep_dev(struct pci_dev *pdev)
> > return pdev->device == PCI_DEVID_RVU_REP;
> > }
> >
> > +int rvu_rep_create(struct otx2_nic *priv);
> > +void rvu_rep_destroy(struct otx2_nic *priv);
> > #endif /* REP_H */
> > --
> > 2.25.1
> >
> >
>
>
> --
> Regards,
> Kalesh A P

2024-04-17 13:48:32

by Geetha sowjanya

[permalink] [raw]
Subject: RE: [EXTERNAL] Re: [net-next PATCH 5/9] octeontx2-af: Add packet path between representor and VF

Hi,

> -----Original Message-----
> From: Kalesh Anakkur Purayil <[email protected]>
> Sent: Wednesday, April 17, 2024 9:46 AM
> To: Geethasowjanya Akula <[email protected]>
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; Sunil
> Kovvuri Goutham <[email protected]>; Subbaraya Sundeep Bhatta
> <[email protected]>; Hariprasad Kelam <[email protected]>
> Subject: [EXTERNAL] Re: [net-next PATCH 5/9] octeontx2-af: Add packet path
> between representor and VF
>
> Prioritize security for external emails: Confirm sender and content safety
> before clicking links or opening attachments
>
> ----------------------------------------------------------------------
> On Wed, Apr 17, 2024 at 9:40 AM Kalesh Anakkur Purayil
> <[email protected]> wrote:
> >
> > On Tue, Apr 16, 2024 at 10:38 AM Geetha sowjanya <[email protected]>
> wrote:
> > >
> > > This patch installs tcam rules to stree traffic representors
> > > and VF when swicthdev mode is set. To support this a HW loopback
> > > channel is reserved. Through this channel packet are routed
> > > between representor and VFs. "ESW_CFG" mbox is defined to
> > > notify AF for installing rules.
> > >
> > > Signed-off-by: Geetha sowjanya <[email protected]>
> > > ---
> > > .../net/ethernet/marvell/octeontx2/af/mbox.h | 7 +
> > > .../net/ethernet/marvell/octeontx2/af/rvu.h | 7 +-
> > > .../marvell/octeontx2/af/rvu_devlink.c | 6 +
> > > .../ethernet/marvell/octeontx2/af/rvu_nix.c | 7 +-
> > > .../ethernet/marvell/octeontx2/af/rvu_rep.c | 241 +++++++++++++++++-
> > > .../marvell/octeontx2/af/rvu_switch.c | 18 +-
> > > .../net/ethernet/marvell/octeontx2/nic/rep.c | 19 ++
> > > 7 files changed, 297 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> > > index c77c02730cf9..3b36da28a8f4 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
> > > @@ -144,6 +144,7 @@ M(LMTST_TBL_SETUP, 0x00a, lmtst_tbl_setup,
> lmtst_tbl_setup_req, \
> > > M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
> > > M(PTP_GET_CAP, 0x00c, ptp_get_cap, msg_req, ptp_get_cap_rsp) \
> > > M(GET_REP_CNT, 0x00d, get_rep_cnt, msg_req, get_rep_cnt_rsp) \
> > > +M(ESW_CFG, 0x00e, esw_cfg, esw_cfg_req, msg_rsp) \
> > > /* CGX mbox IDs (range 0x200 - 0x3FF) */ \
> > > M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
> > > M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
> > > @@ -1532,6 +1533,12 @@ struct get_rep_cnt_rsp {
> > > u64 rsvd;
> > > };
> > >
> > > +struct esw_cfg_req {
> > > + struct mbox_msghdr hdr;
> > > + u8 ena;
> > > + u64 rsvd;
> > > +};
> > > +
> > > struct flow_msg {
> > > unsigned char dmac[6];
> > > unsigned char smac[6];
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > > index 1d76d52d7a5d..c8572d79a968 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > > @@ -596,6 +596,7 @@ struct rvu {
> > > u16 rep_pcifunc;
> > > int rep_cnt;
> > > u16 *rep2pfvf_map;
> > > + u8 rep_mode;
> > > };
> > >
> > > static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64
> val)
> > > @@ -1025,7 +1026,7 @@ int rvu_ndc_fix_locked_cacheline(struct rvu
> *rvu, int blkaddr);
> > > /* RVU Switch */
> > > void rvu_switch_enable(struct rvu *rvu);
> > > void rvu_switch_disable(struct rvu *rvu);
> > > -void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc);
> > > +void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
> > > void rvu_switch_enable_lbk_link(struct rvu *rvu, u16 pcifunc, bool ena);
> > >
> > > int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8
> dir,
> > > @@ -1039,4 +1040,8 @@ int rvu_mcs_flr_handler(struct rvu *rvu, u16
> pcifunc);
> > > void rvu_mcs_ptp_cfg(struct rvu *rvu, u8 rpm_id, u8 lmac_id, bool ena);
> > > void rvu_mcs_exit(struct rvu *rvu);
> > >
> > > +/* Representor APIs */
> > > +int rvu_rep_pf_init(struct rvu *rvu);
> > > +int rvu_rep_install_mcam_rules(struct rvu *rvu);
> > > +void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
> > > #endif /* RVU_H */
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> > > index 96c04f7d93f8..8a3b7fb61883 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> > > @@ -1464,6 +1464,9 @@ static int rvu_devlink_eswitch_mode_get(struct
> devlink *devlink, u16 *mode)
> > > struct rvu *rvu = rvu_dl->rvu;
> > > struct rvu_switch *rswitch;
> > >
> > > + if (rvu->rep_mode)
> > > + return -EOPNOTSUPP;
> > > +
> > > rswitch = &rvu->rswitch;
> > > *mode = rswitch->mode;
> > >
> > > @@ -1477,6 +1480,9 @@ static int rvu_devlink_eswitch_mode_set(struct
> devlink *devlink, u16 mode,
> > > struct rvu *rvu = rvu_dl->rvu;
> > > struct rvu_switch *rswitch;
> > >
> > > + if (rvu->rep_mode)
> > > + return -EOPNOTSUPP;
> > > +
> > > rswitch = &rvu->rswitch;
> > > switch (mode) {
> > > case DEVLINK_ESWITCH_MODE_LEGACY:
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> > > index 4ef5bb7b337f..75d5c1bc00e1 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> > > @@ -2738,7 +2738,7 @@ void rvu_nix_tx_tl2_cfg(struct rvu *rvu, int
> blkaddr, u16 pcifunc,
> > > int schq;
> > > u64 cfg;
> > >
> > > - if (!is_pf_cgxmapped(rvu, pf))
> > > + if (!is_pf_cgxmapped(rvu, pf) && !is_rep_dev(rvu, pcifunc))
> > > return;
> > >
> > > cfg = enable ? (BIT_ULL(12) | RVU_SWITCH_LBK_CHAN) : 0;
> > > @@ -4368,8 +4368,6 @@ int
> rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
> > > if (test_bit(PF_SET_VF_TRUSTED, &pfvf->flags) && from_vf)
> > > ether_addr_copy(pfvf->default_mac, req->mac_addr);
> > >
> > > - rvu_switch_update_rules(rvu, pcifunc);
> > > -
> > > return 0;
> > > }
> > >
> > > @@ -5159,7 +5157,7 @@ int rvu_mbox_handler_nix_lf_start_rx(struct
> rvu *rvu, struct msg_req *req,
> > > pfvf = rvu_get_pfvf(rvu, pcifunc);
> > > set_bit(NIXLF_INITIALIZED, &pfvf->flags);
> > >
> > > - rvu_switch_update_rules(rvu, pcifunc);
> > > + rvu_switch_update_rules(rvu, pcifunc, true);
> > >
> > > return rvu_cgx_start_stop_io(rvu, pcifunc, true);
> > > }
> > > @@ -5187,6 +5185,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu
> *rvu, struct msg_req *req,
> > > if (err)
> > > return err;
> > >
> > > + rvu_switch_update_rules(rvu, pcifunc, false);
> > > rvu_cgx_tx_enable(rvu, pcifunc, true);
> > >
> > > return 0;
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> > > index d07cb356d3d6..5c015e8dfbbe 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c
> > > @@ -13,6 +13,246 @@
> > > #include "rvu.h"
> > > #include "rvu_reg.h"
> > >
> > > +static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
> > > +{
> > > + int id;
> > > +
> > > + for (id = 0; id < rvu->rep_cnt; id++)
> > > + if (rvu->rep2pfvf_map[id] == pcifunc)
> > > + return id;
> > > + return -ENODEV;
> > > +}
> > > +
> > > +static int rvu_rep_tx_vlan_cfg(struct rvu *rvu, u16 pcifunc,
> > > + u16 vlan_tci, int *vidx)
> > > +{
> > > + struct nix_vtag_config req = {0};
> > > + struct nix_vtag_config_rsp rsp = {0};
> [Kalesh] RCT order. Also I think {0} is not needed and you can just use {}
Ack.
> > > + u64 etype = ETH_P_8021Q;
> > > + int err;
> > > +
> > > + /* Insert vlan tag */
> > > + req.hdr.pcifunc = pcifunc;
> > > + req.vtag_size = VTAGSIZE_T4;
> > > + req.cfg_type = 0; /* tx vlan cfg */
> > > + req.tx.cfg_vtag0 = true;
> > > + req.tx.vtag0 = etype << 48 | ntohs(vlan_tci);
> > > +
> > > + err = rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
> > > + if (err) {
> > > + dev_err(rvu->dev, "Tx vlan config failed\n");
> > > + return err;
> > > + }
> > > + *vidx = rsp.vtag0_idx;
> > > + return 0;
> > > +}
> > > +
> > > +static int rvu_rep_rx_vlan_cfg(struct rvu *rvu, u16 pcifunc)
> > > +{
> > > + struct nix_vtag_config req = {0};
> > > + struct nix_vtag_config_rsp rsp;
> > > +
> > > + /* config strip, capture and size */
> > > + req.hdr.pcifunc = pcifunc;
> > > + req.vtag_size = VTAGSIZE_T4;
> > > + req.cfg_type = 1; /* rx vlan cfg */
> > > + req.rx.vtag_type = NIX_AF_LFX_RX_VTAG_TYPE0;
> > > + req.rx.strip_vtag = true;
> > > + req.rx.capture_vtag = false;
> > > +
> > > + return rvu_mbox_handler_nix_vtag_cfg(rvu, &req, &rsp);
> > > +}
> > > +
> > > +static int rvu_rep_install_rx_rule(struct rvu *rvu, u16 pcifunc,
> > > + u16 entry, bool rte)
> > > +{
> > > + struct npc_install_flow_req req = { 0 };
> > > + struct npc_install_flow_rsp rsp = { 0 };
> > > + struct rvu_pfvf *pfvf;
> > > + u16 vlan_tci, rep_id;
> > > +
> > > + pfvf = rvu_get_pfvf(rvu, pcifunc);
> > > +
> > > + /* To stree the traffic from Representee to Representor */
> [Kalesh] Typo. did you mean steer?
> > > + rep_id = (u16)rvu_rep_get_vlan_id(rvu, pcifunc);
> > > + if (rte) {
> > > + vlan_tci = rep_id | 0x1ull << 8;
> > > + req.vf = rvu->rep_pcifunc;
> > > + req.op = NIX_RX_ACTIONOP_UCAST;
> > > + req.index = rep_id;
> > > + } else {
> > > + vlan_tci = rep_id;
> > > + req.vf = pcifunc;
> > > + req.op = NIX_RX_ACTION_DEFAULT;
> > > + }
> > > +
> > > + rvu_rep_rx_vlan_cfg(rvu, req.vf);
> > > + req.entry = entry;
> > > + req.hdr.pcifunc = 0; /* AF is requester */
> > > + req.features = BIT_ULL(NPC_OUTER_VID) |
> BIT_ULL(NPC_VLAN_ETYPE_CTAG);
> > > + req.vtag0_valid = true;
> > > + req.vtag0_type = NIX_AF_LFX_RX_VTAG_TYPE0;
> > > + req.packet.vlan_etype = ETH_P_8021Q;
> > > + req.mask.vlan_etype = ETH_P_8021Q;
> > > + req.packet.vlan_tci = vlan_tci;
> > > + req.mask.vlan_tci = 0xffff;
> > > +
> > > + req.channel = RVU_SWITCH_LBK_CHAN;
> > > + req.chan_mask = 0xffff;
> > > + req.intf = pfvf->nix_rx_intf;
> > > +
> > > + return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
> > > +}
> > > +
> > > +static int rvu_rep_install_tx_rule(struct rvu *rvu, u16 pcifunc, u16 entry,
> > > + bool rte)
> > > +{
> > > + struct npc_install_flow_req req = { 0 };
> > > + struct npc_install_flow_rsp rsp = { 0 };
> > > + struct rvu_pfvf *pfvf;
> > > + int vidx, err;
> > > + u16 vlan_tci;
> > > + u8 lbkid;
> > > +
> > > + pfvf = rvu_get_pfvf(rvu, pcifunc);
> > > + vlan_tci = rvu_rep_get_vlan_id(rvu, pcifunc);
> > > + if (rte)
> > > + vlan_tci |= 0x1ull << 8;
> > > +
> > > + err = rvu_rep_tx_vlan_cfg(rvu, pcifunc, vlan_tci, &vidx);
> > > + if (err)
> > > + return err;
> > > +
> > > + lbkid = pfvf->nix_blkaddr == BLKADDR_NIX0 ? 0 : 1;
> > > + req.hdr.pcifunc = 0; /* AF is requester */
> > > + if (rte) {
> > > + req.vf = pcifunc;
> > > + } else {
> > > + req.vf = rvu->rep_pcifunc;
> > > + req.packet.sq_id = vlan_tci;
> > > + req.mask.sq_id = 0xffff;
> > > + }
> > > +
> > > + req.entry = entry;
> > > + req.intf = pfvf->nix_tx_intf;
> > > + req.op = NIX_TX_ACTIONOP_UCAST_CHAN;
> > > + req.index = (lbkid << 8) | RVU_SWITCH_LBK_CHAN;
> > > + req.set_cntr = 1;
> > > + req.vtag0_def = vidx;
> > > + req.vtag0_op = 1;
> > > + return rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp);
> > > +}
> > > +
> > > +int rvu_rep_install_mcam_rules(struct rvu *rvu)
> > > +{
> > > + struct rvu_switch *rswitch = &rvu->rswitch;
> > > + u16 start = rswitch->start_entry;
> > > + struct rvu_hwinfo *hw = rvu->hw;
> > > + u16 pcifunc, entry = 0;
> > > + int pf, vf, numvfs;
> > > + int err, nixlf, i;
> > > + u8 rep;
> > > +
> > > + for (pf = 1; pf < hw->total_pfs; pf++) {
> > > + if (!is_pf_cgxmapped(rvu, pf))
> > > + continue;
> > > +
> > > + pcifunc = pf << RVU_PFVF_PF_SHIFT;
> > > + rvu_get_nix_blkaddr(rvu, pcifunc);
> > > + rep = true;
> > > + for (i = 0; i < 2; i++) {
> > > + err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry, rep);
> > > + if (err)
> > > + return err;
> > > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > > +
> > > + err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry, rep);
> > > + if (err)
> > > + return err;
> > > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > > + rep = false;
> > > + }
> > > +
> > > + rvu_get_pf_numvfs(rvu, pf, &numvfs, NULL);
> > > + for (vf = 0; vf < numvfs; vf++) {
> > > + pcifunc = pf << RVU_PFVF_PF_SHIFT |
> > > + ((vf + 1) & RVU_PFVF_FUNC_MASK);
> > > + rvu_get_nix_blkaddr(rvu, pcifunc);
> > > +
> > > + /* Skip installimg rules if nixlf is not attached */
> > > + err = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
> > > + if (err)
> > > + continue;
> > > + rep = true;
> > > + for (i = 0; i < 2; i++) {
> > > + err = rvu_rep_install_rx_rule(rvu, pcifunc, start + entry,
> rep);
> > > + if (err)
> > > + return err;
> > > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > > +
> > > + err = rvu_rep_install_tx_rule(rvu, pcifunc, start + entry,
> rep);
> > > + if (err)
> > > + return err;
> > > + rswitch->entry2pcifunc[entry++] = pcifunc;
> > > + rep = false;
> > > + }
> > > + }
> > > + }
> > > + return 0;
> > > +}
> > > +
> > > +void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
> > > +{
> > > + struct rvu_switch *rswitch = &rvu->rswitch;
> > > + struct npc_mcam *mcam = &rvu->hw->mcam;
> [Kalesh: maintain RCT order
> > > + u32 max = rswitch->used_entries;
> > > + int blkaddr;
> > > + u16 entry;
> > > +
> > > + if (!rswitch->used_entries)
> > > + return;
> > > +
> > > + blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
> > > +
> [Kalesh] No need of a blank line here
> > > + if (blkaddr < 0)
> > > + return;
> > > +
> > > + rvu_switch_enable_lbk_link(rvu, pcifunc, ena);
> > > + mutex_lock(&mcam->lock);
> > > + for (entry = 0; entry < max; entry++) {
> > > + if (rswitch->entry2pcifunc[entry] == pcifunc)
> > > + npc_enable_mcam_entry(rvu, mcam, blkaddr, entry, ena);
> > > + }
> > > + mutex_unlock(&mcam->lock);
> > > +}
> > > +
> > > +int rvu_rep_pf_init(struct rvu *rvu)
> > > +{
> > > + u16 pcifunc = rvu->rep_pcifunc;
> > > + struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
> > > +
> > > + set_bit(NIXLF_INITIALIZED, &pfvf->flags);
> > > + rvu_switch_enable_lbk_link(rvu, pcifunc, true);
> > > + rvu_rep_rx_vlan_cfg(rvu, pcifunc);
> > > + return 0;
> [Kalesh] This function returns 0 unconditionally, maybe you can change
> it to void?'
Ack.
> > > +}
> > > +
> > > +int rvu_mbox_handler_esw_cfg(struct rvu *rvu, struct esw_cfg_req *req,
> > > + struct msg_rsp *rsp)
> > > +{
> > > + if (req->hdr.pcifunc != rvu->rep_pcifunc)
> > > + return 0;
> > > +
> > > + rvu->rep_mode = req->ena;
> > > +
> > > + if (req->ena)
> > > + rvu_switch_enable(rvu);
> > > + else
> > > + rvu_switch_disable(rvu);
> > > +
> > > + return 0;
> [Kalesh] This function returns 0 unconditionally, maybe you can change
> it to void?
> > > +}
> > > +
> > > int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu, struct msg_req *req,
> > > struct get_rep_cnt_rsp *rsp)
> > > {
> > > @@ -45,4 +285,3 @@ int rvu_mbox_handler_get_rep_cnt(struct rvu *rvu,
> struct msg_req *req,
> > > }
> > > return 0;
> > > }
> > > -
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> > > index ceb81eebf65e..268efb7c1c15 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
> > > @@ -166,6 +166,8 @@ void rvu_switch_enable(struct rvu *rvu)
> > >
> > > alloc_req.contig = true;
> > > alloc_req.count = rvu->cgx_mapped_pfs + rvu->cgx_mapped_vfs;
> > > + if (rvu->rep_mode)
> > > + alloc_req.count = alloc_req.count * 4;
> > > ret = rvu_mbox_handler_npc_mcam_alloc_entry(rvu, &alloc_req,
> > > &alloc_rsp);
> > > if (ret) {
> > > @@ -189,7 +191,12 @@ void rvu_switch_enable(struct rvu *rvu)
> > > rswitch->used_entries = alloc_rsp.count;
> > > rswitch->start_entry = alloc_rsp.entry;
> > >
> > > - ret = rvu_switch_install_rules(rvu);
> > > + if (rvu->rep_mode) {
> > > + rvu_rep_pf_init(rvu);
> > > + ret = rvu_rep_install_mcam_rules(rvu);
> > > + } else {
> > > + ret = rvu_switch_install_rules(rvu);
> > > + }
> > > if (ret)
> > > goto uninstall_rules;
> > >
> > > @@ -222,6 +229,9 @@ void rvu_switch_disable(struct rvu *rvu)
> > > if (!rswitch->used_entries)
> > > return;
> > >
> > > + if (rvu->rep_mode)
> > > + goto free_ents;
> > > +
> > > for (pf = 1; pf < hw->total_pfs; pf++) {
> > > if (!is_pf_cgxmapped(rvu, pf))
> > > continue;
> > > @@ -249,6 +259,7 @@ void rvu_switch_disable(struct rvu *rvu)
> > > }
> > > }
> > >
> > > +free_ents:
> > > uninstall_req.start = rswitch->start_entry;
> > > uninstall_req.end = rswitch->start_entry + rswitch->used_entries - 1;
> > > free_req.all = 1;
> > > @@ -258,12 +269,15 @@ void rvu_switch_disable(struct rvu *rvu)
> > > kfree(rswitch->entry2pcifunc);
> > > }
> > >
> > > -void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc)
> > > +void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc, bool ena)
> > > {
> > > struct rvu_switch *rswitch = &rvu->rswitch;
> > > u32 max = rswitch->used_entries;
> > > u16 entry;
> > >
> > > + if (rvu->rep_mode)
> > > + return rvu_rep_update_rules(rvu, pcifunc, ena);
> > > +
> > > if (!rswitch->used_entries)
> > > return;
> > >
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > > index 187b00156bcd..1329617f8d6f 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > > @@ -28,6 +28,22 @@ MODULE_DESCRIPTION(DRV_STRING);
> > > MODULE_LICENSE("GPL");
> > > MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
> > >
> > > +static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
> > > +{
> > > + struct esw_cfg_req *req;
> > > +
> > > + mutex_lock(&priv->mbox.lock);
> > > + req = otx2_mbox_alloc_msg_esw_cfg(&priv->mbox);
> > > + if (!req) {
> > > + mutex_unlock(&priv->mbox.lock);
> > > + return -ENOMEM;
> > > + }
> > > + req->ena = ena;
> > > + otx2_sync_mbox_msg(&priv->mbox);
> > > + mutex_unlock(&priv->mbox.lock);
> > > + return 0;
> > > +}
> > > +
> > > static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device
> *dev)
> > > {
> > > struct rep_dev *rep = netdev_priv(dev);
> > > @@ -170,6 +186,8 @@ static void rvu_rep_free_netdev(struct otx2_nic
> *priv)
> > >
> > > void rvu_rep_destroy(struct otx2_nic *priv)
> > > {
> > > + /* Remove mcam rules */
> > > + rvu_eswitch_config(priv, false);
> > > rvu_rep_free_cq_rsrc(priv);
> > > rvu_rep_free_netdev(priv);
> > > }
> > > @@ -221,6 +239,7 @@ int rvu_rep_create(struct otx2_nic *priv)
> > > if (err)
> > > goto exit;
> > >
> > > + rvu_eswitch_config(priv, true);
> > > return 0;
> > > exit:
> > > rvu_rep_free_netdev(priv);
> > > --
> > > 2.25.1
> > >
> > >
> >
> >
> > --
> > Regards,
> > Kalesh A P
>
>
>
> --
> Regards,
> Kalesh A P

Thanks for the feedback. Will submit v2 addressing all the issues.

2024-04-17 15:24:38

by Dan Carpenter

[permalink] [raw]
Subject: Re: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

Hi Geetha,

kernel test robot noticed the following build warnings:

url: https://github.com/intel-lab-lkp/linux/commits/Geetha-sowjanya/octeontx2-pf-Refactoring-RVU-driver/20240416-131052
base: net-next/main
patch link: https://lore.kernel.org/r/20240416050616.6056-4-gakula%40marvell.com
patch subject: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev
config: alpha-randconfig-r081-20240417 (https://download.01.org/0day-ci/archive/20240417/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/net/ethernet/marvell/octeontx2/nic/rep.c:170 rvu_rep_create() error: dereferencing freed memory 'ndev'

vim +/ndev +170 drivers/net/ethernet/marvell/octeontx2/nic/rep.c

f9a5b510759eeb Geetha sowjanya 2024-04-16 131
f9a5b510759eeb Geetha sowjanya 2024-04-16 132 int rvu_rep_create(struct otx2_nic *priv)
f9a5b510759eeb Geetha sowjanya 2024-04-16 133 {
f9a5b510759eeb Geetha sowjanya 2024-04-16 134 int rep_cnt = priv->rep_cnt;
f9a5b510759eeb Geetha sowjanya 2024-04-16 135 struct net_device *ndev;
f9a5b510759eeb Geetha sowjanya 2024-04-16 136 struct rep_dev *rep;
f9a5b510759eeb Geetha sowjanya 2024-04-16 137 int rep_id, err;
f9a5b510759eeb Geetha sowjanya 2024-04-16 138 u16 pcifunc;
f9a5b510759eeb Geetha sowjanya 2024-04-16 139
f9a5b510759eeb Geetha sowjanya 2024-04-16 140 priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
f9a5b510759eeb Geetha sowjanya 2024-04-16 141 if (!priv->reps)
f9a5b510759eeb Geetha sowjanya 2024-04-16 142 return -ENOMEM;
f9a5b510759eeb Geetha sowjanya 2024-04-16 143
f9a5b510759eeb Geetha sowjanya 2024-04-16 144 for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
f9a5b510759eeb Geetha sowjanya 2024-04-16 145 ndev = alloc_etherdev(sizeof(*rep));
f9a5b510759eeb Geetha sowjanya 2024-04-16 146 if (!ndev) {
f9a5b510759eeb Geetha sowjanya 2024-04-16 147 dev_err(priv->dev, "PFVF representor:%d creation failed\n", rep_id);
f9a5b510759eeb Geetha sowjanya 2024-04-16 148 err = -ENOMEM;
f9a5b510759eeb Geetha sowjanya 2024-04-16 149 goto exit;
f9a5b510759eeb Geetha sowjanya 2024-04-16 150 }
f9a5b510759eeb Geetha sowjanya 2024-04-16 151
f9a5b510759eeb Geetha sowjanya 2024-04-16 152 rep = netdev_priv(ndev);
f9a5b510759eeb Geetha sowjanya 2024-04-16 153 priv->reps[rep_id] = rep;
f9a5b510759eeb Geetha sowjanya 2024-04-16 154 rep->mdev = priv;
f9a5b510759eeb Geetha sowjanya 2024-04-16 155 rep->netdev = ndev;
f9a5b510759eeb Geetha sowjanya 2024-04-16 156 rep->rep_id = rep_id;
f9a5b510759eeb Geetha sowjanya 2024-04-16 157
f9a5b510759eeb Geetha sowjanya 2024-04-16 158 ndev->min_mtu = OTX2_MIN_MTU;
f9a5b510759eeb Geetha sowjanya 2024-04-16 159 ndev->max_mtu = priv->hw.max_mtu;
f9a5b510759eeb Geetha sowjanya 2024-04-16 160 pcifunc = priv->rep_pf_map[rep_id];
f9a5b510759eeb Geetha sowjanya 2024-04-16 161 rep->pcifunc = pcifunc;
f9a5b510759eeb Geetha sowjanya 2024-04-16 162
f9a5b510759eeb Geetha sowjanya 2024-04-16 163 snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
f9a5b510759eeb Geetha sowjanya 2024-04-16 164 rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
f9a5b510759eeb Geetha sowjanya 2024-04-16 165
f9a5b510759eeb Geetha sowjanya 2024-04-16 166 eth_hw_addr_random(ndev);
f9a5b510759eeb Geetha sowjanya 2024-04-16 167 if (register_netdev(ndev)) {

err = register_netdev(ndev);
if (err) {

f9a5b510759eeb Geetha sowjanya 2024-04-16 168 dev_err(priv->dev, "PFVF reprentator registration failed\n");
f9a5b510759eeb Geetha sowjanya 2024-04-16 169 free_netdev(ndev);
^^^^
freed

f9a5b510759eeb Geetha sowjanya 2024-04-16 @170 ndev->netdev_ops = NULL;
^^^^^^^^^^^^^^^^^^^^^^^
Use after free

f9a5b510759eeb Geetha sowjanya 2024-04-16 171 goto exit;
f9a5b510759eeb Geetha sowjanya 2024-04-16 172 }
f9a5b510759eeb Geetha sowjanya 2024-04-16 173 }
f9a5b510759eeb Geetha sowjanya 2024-04-16 174 err = rvu_rep_napi_init(priv);
f9a5b510759eeb Geetha sowjanya 2024-04-16 175 if (err)
f9a5b510759eeb Geetha sowjanya 2024-04-16 176 goto exit;
f9a5b510759eeb Geetha sowjanya 2024-04-16 177
f9a5b510759eeb Geetha sowjanya 2024-04-16 178 return 0;
f9a5b510759eeb Geetha sowjanya 2024-04-16 179 exit:
f9a5b510759eeb Geetha sowjanya 2024-04-16 180 rvu_rep_free_netdev(priv);

rvu_rep_free_netdev() also calls free_netdev() so it's a double free. I
would normally write this as:

exit:
while (--rep_id >= 0) {
unregister_netdev(priv->reps[rep_id]);
free_netdev(priv->reps[rep_id]);
}

return err;

When you write it that way then rvu_rep_free_netdev() can be made easier
as well:

static void rvu_rep_free_netdev(struct otx2_nic *priv)
{
int rep_id;

for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++) {
unregister_netdev(priv->reps[rep_id]);
free_netdev(priv->reps[rep_id]);
}
}

There should be no need to call devm_kfree(priv->dev, priv->reps);.

f9a5b510759eeb Geetha sowjanya 2024-04-16 @181 return err;
f9a5b510759eeb Geetha sowjanya 2024-04-16 182 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


2024-04-17 15:49:34

by Dan Carpenter

[permalink] [raw]
Subject: Re: [net-next PATCH 3/9] octeontx2-pf: Create representor netdev

On Wed, Apr 17, 2024 at 06:24:13PM +0300, Dan Carpenter wrote:
> f9a5b510759eeb Geetha sowjanya 2024-04-16 132 int rvu_rep_create(struct otx2_nic *priv)
> f9a5b510759eeb Geetha sowjanya 2024-04-16 133 {
> f9a5b510759eeb Geetha sowjanya 2024-04-16 134 int rep_cnt = priv->rep_cnt;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 135 struct net_device *ndev;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 136 struct rep_dev *rep;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 137 int rep_id, err;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 138 u16 pcifunc;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 139
> f9a5b510759eeb Geetha sowjanya 2024-04-16 140 priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
> f9a5b510759eeb Geetha sowjanya 2024-04-16 141 if (!priv->reps)
> f9a5b510759eeb Geetha sowjanya 2024-04-16 142 return -ENOMEM;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 143
> f9a5b510759eeb Geetha sowjanya 2024-04-16 144 for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
> f9a5b510759eeb Geetha sowjanya 2024-04-16 145 ndev = alloc_etherdev(sizeof(*rep));
> f9a5b510759eeb Geetha sowjanya 2024-04-16 146 if (!ndev) {
> f9a5b510759eeb Geetha sowjanya 2024-04-16 147 dev_err(priv->dev, "PFVF representor:%d creation failed\n", rep_id);
> f9a5b510759eeb Geetha sowjanya 2024-04-16 148 err = -ENOMEM;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 149 goto exit;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 150 }
> f9a5b510759eeb Geetha sowjanya 2024-04-16 151
> f9a5b510759eeb Geetha sowjanya 2024-04-16 152 rep = netdev_priv(ndev);
> f9a5b510759eeb Geetha sowjanya 2024-04-16 153 priv->reps[rep_id] = rep;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 154 rep->mdev = priv;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 155 rep->netdev = ndev;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 156 rep->rep_id = rep_id;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 157
> f9a5b510759eeb Geetha sowjanya 2024-04-16 158 ndev->min_mtu = OTX2_MIN_MTU;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 159 ndev->max_mtu = priv->hw.max_mtu;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 160 pcifunc = priv->rep_pf_map[rep_id];
> f9a5b510759eeb Geetha sowjanya 2024-04-16 161 rep->pcifunc = pcifunc;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 162
> f9a5b510759eeb Geetha sowjanya 2024-04-16 163 snprintf(ndev->name, sizeof(ndev->name), "r%dp%dv%d", rep_id,
> f9a5b510759eeb Geetha sowjanya 2024-04-16 164 rvu_get_pf(pcifunc), (pcifunc & RVU_PFVF_FUNC_MASK));
> f9a5b510759eeb Geetha sowjanya 2024-04-16 165
> f9a5b510759eeb Geetha sowjanya 2024-04-16 166 eth_hw_addr_random(ndev);
> f9a5b510759eeb Geetha sowjanya 2024-04-16 167 if (register_netdev(ndev)) {
>
> err = register_netdev(ndev);
> if (err) {
>
> f9a5b510759eeb Geetha sowjanya 2024-04-16 168 dev_err(priv->dev, "PFVF reprentator registration failed\n");
> f9a5b510759eeb Geetha sowjanya 2024-04-16 169 free_netdev(ndev);
> ^^^^
> freed
>
> f9a5b510759eeb Geetha sowjanya 2024-04-16 @170 ndev->netdev_ops = NULL;
> ^^^^^^^^^^^^^^^^^^^^^^^
> Use after free
>
> f9a5b510759eeb Geetha sowjanya 2024-04-16 171 goto exit;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 172 }
> f9a5b510759eeb Geetha sowjanya 2024-04-16 173 }
> f9a5b510759eeb Geetha sowjanya 2024-04-16 174 err = rvu_rep_napi_init(priv);
> f9a5b510759eeb Geetha sowjanya 2024-04-16 175 if (err)
> f9a5b510759eeb Geetha sowjanya 2024-04-16 176 goto exit;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 177
> f9a5b510759eeb Geetha sowjanya 2024-04-16 178 return 0;
> f9a5b510759eeb Geetha sowjanya 2024-04-16 179 exit:
> f9a5b510759eeb Geetha sowjanya 2024-04-16 180 rvu_rep_free_netdev(priv);
>
> rvu_rep_free_netdev() also calls free_netdev() so it's a double free.

Actually the rep->netdev->netdev_ops check in rvu_rep_free_netdev() was
supposed to prevent the double free. But since rep->netdev is already
freed, then it's another use after free. You could use a different flag
instead of rep->netdev->netdev_ops to mean "don't free this". But
really, it's just better to write it how I have suggested.

My patch adds some duplicate code but when you remove the conditions in
rvu_rep_free_netdev() and the "ndev->netdev_ops = NULL" assignment, then
overall it's fewer lines of code this way.

https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/

regards,
dan carpenter


2024-04-17 18:09:01

by Dan Carpenter

[permalink] [raw]
Subject: Re: [net-next PATCH 5/9] octeontx2-af: Add packet path between representor and VF

Hi Geetha,

kernel test robot noticed the following build warnings:

url: https://github.com/intel-lab-lkp/linux/commits/Geetha-sowjanya/octeontx2-pf-Refactoring-RVU-driver/20240416-131052
base: net-next/main
patch link: https://lore.kernel.org/r/20240416050616.6056-6-gakula%40marvell.com
patch subject: [net-next PATCH 5/9] octeontx2-af: Add packet path between representor and VF
config: alpha-randconfig-r081-20240417 (https://download.01.org/0day-ci/archive/20240417/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c:23 rvu_rep_get_vlan_id() warn: signedness bug returning '(-19)'

vim +23 drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c

5c25d7a685d906 Geetha sowjanya 2024-04-16 16 static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
^^^
u16 type

5c25d7a685d906 Geetha sowjanya 2024-04-16 17 {
5c25d7a685d906 Geetha sowjanya 2024-04-16 18 int id;
5c25d7a685d906 Geetha sowjanya 2024-04-16 19
5c25d7a685d906 Geetha sowjanya 2024-04-16 20 for (id = 0; id < rvu->rep_cnt; id++)
5c25d7a685d906 Geetha sowjanya 2024-04-16 21 if (rvu->rep2pfvf_map[id] == pcifunc)
5c25d7a685d906 Geetha sowjanya 2024-04-16 22 return id;
5c25d7a685d906 Geetha sowjanya 2024-04-16 @23 return -ENODEV;
^^^^^^^^^^^^^^

5c25d7a685d906 Geetha sowjanya 2024-04-16 24 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki