Skip to contentSkip to conversation

Add Marvell CNXK common driver

PATCH Superseded Nithin Dabilpuram 3 participants 275 messages Mar 5, 2021 – Apr 8, 2021 Arm/Amlogic Meson SoC support Page 5 of 5

lore
Share & tools
lore
#230 lore raw

PATCH v5 9/52 common/cnxk: add VF support to base device class

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add VF specific handling such as BAR4 setup, forwarding VF mbox messages to AF and vice-versa, VF FLR handling etc.

---
 drivers/common/cnxk/roc_dev.c      | 857 ++++++++++++++++++++++++++++++++++++-
 drivers/common/cnxk/roc_dev_priv.h |  42 ++
 2 files changed, 879 insertions(+), 20 deletions(-)
drivers/common/cnxk/roc_dev.c +837 -20
index 380c71b..4cd5978 100644
@@ -17,6 +17,337 @@
 /* Single Root I/O Virtualization */
 #define ROC_PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
 
+static void *
+mbox_mem_map(off_t off, size_t size)
+{
+	void *va = MAP_FAILED;
+	int mem_fd;
+
+	if (size <= 0 || !off) {
+		plt_err("Invalid mbox area off 0x%lx size %lu", off, size);
+		goto error;
+	}
+
+	mem_fd = open("/dev/mem", O_RDWR);
+	if (mem_fd < 0)
+		goto error;
+
+	va = plt_mmap(NULL, size, PLT_PROT_READ | PLT_PROT_WRITE,
+		      PLT_MAP_SHARED, mem_fd, off);
+	close(mem_fd);
+
+	if (va == MAP_FAILED)
+		plt_err("Failed to mmap sz=0x%zx, fd=%d, off=%jd", size, mem_fd,
+			(intmax_t)off);
+error:
+	return va;
+}
+
+static void
+mbox_mem_unmap(void *va, size_t size)
+{
+	if (va)
+		munmap(va, size);
+}
+
+static int
+pf_af_sync_msg(struct dev *dev, struct mbox_msghdr **rsp)
+{
+	uint32_t timeout = 0, sleep = 1;
+	struct mbox *mbox = dev->mbox;
+	struct mbox_dev *mdev = &mbox->dev[0];
+
+	volatile uint64_t int_status;
+	struct mbox_msghdr *msghdr;
+	uint64_t off;
+	int rc = 0;
+
+	/* We need to disable PF interrupts. We are in timer interrupt */
+	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1C);
+
+	/* Send message */
+	mbox_msg_send(mbox, 0);
+
+	do {
+		plt_delay_ms(sleep);
+		timeout += sleep;
+		if (timeout >= mbox->rsp_tmo) {
+			plt_err("Message timeout: %dms", mbox->rsp_tmo);
+			rc = -EIO;
+			break;
+		}
+		int_status = plt_read64(dev->bar2 + RVU_PF_INT);
+	} while ((int_status & 0x1) != 0x1);
+
+	/* Clear */
+	plt_write64(int_status, dev->bar2 + RVU_PF_INT);
+
+	/* Enable interrupts */
+	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1S);
+
+	if (rc == 0) {
+		/* Get message */
+		off = mbox->rx_start +
+		      PLT_ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
+		msghdr = (struct mbox_msghdr *)((uintptr_t)mdev->mbase + off);
+		if (rsp)
+			*rsp = msghdr;
+		rc = msghdr->rc;
+	}
+
+	return rc;
+}
+
+static int
+af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
+{
+	uint32_t timeout = 0, sleep = 1;
+	struct mbox *mbox = dev->mbox;
+	struct mbox_dev *mdev = &mbox->dev[0];
+	volatile uint64_t int_status;
+	struct mbox_hdr *req_hdr;
+	struct mbox_msghdr *msg;
+	struct mbox_msghdr *rsp;
+	uint64_t offset;
+	size_t size;
+	int i;
+
+	/* We need to disable PF interrupts. We are in timer interrupt */
+	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1C);
+
+	/* Send message */
+	mbox_msg_send(mbox, 0);
+
+	do {
+		plt_delay_ms(sleep);
+		timeout++;
+		if (timeout >= mbox->rsp_tmo) {
+			plt_err("Routed messages %d timeout: %dms", num_msg,
+				mbox->rsp_tmo);
+			break;
+		}
+		int_status = plt_read64(dev->bar2 + RVU_PF_INT);
+	} while ((int_status & 0x1) != 0x1);
+
+	/* Clear */
+	plt_write64(~0ull, dev->bar2 + RVU_PF_INT);
+
+	/* Enable interrupts */
+	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1S);
+
+	plt_spinlock_lock(&mdev->mbox_lock);
+
+	req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
+	if (req_hdr->num_msgs != num_msg)
+		plt_err("Routed messages: %d received: %d", num_msg,
+			req_hdr->num_msgs);
+
+	/* Get messages from mbox */
+	offset = mbox->rx_start +
+		 PLT_ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
+	for (i = 0; i < req_hdr->num_msgs; i++) {
+		msg = (struct mbox_msghdr *)((uintptr_t)mdev->mbase + offset);
+		size = mbox->rx_start + msg->next_msgoff - offset;
+
+		/* Reserve PF/VF mbox message */
+		size = PLT_ALIGN(size, MBOX_MSG_ALIGN);
+		rsp = mbox_alloc_msg(&dev->mbox_vfpf, vf, size);
+		mbox_rsp_init(msg->id, rsp);
+
+		/* Copy message from AF<->PF mbox to PF<->VF mbox */
+		mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr),
+			    (uint8_t *)msg + sizeof(struct mbox_msghdr),
+			    size - sizeof(struct mbox_msghdr));
+
+		/* Set status and sender pf_func data */
+		rsp->rc = msg->rc;
+		rsp->pcifunc = msg->pcifunc;
+
+		offset = mbox->rx_start + msg->next_msgoff;
+	}
+	plt_spinlock_unlock(&mdev->mbox_lock);
+
+	return req_hdr->num_msgs;
+}
+
+static int
+vf_pf_process_msgs(struct dev *dev, uint16_t vf)
+{
+	struct mbox *mbox = &dev->mbox_vfpf;
+	struct mbox_dev *mdev = &mbox->dev[vf];
+	struct mbox_hdr *req_hdr;
+	struct mbox_msghdr *msg;
+	int offset, routed = 0;
+	size_t size;
+	uint16_t i;
+
+	req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
+	if (!req_hdr->num_msgs)
+		return 0;
+
+	offset = mbox->rx_start + PLT_ALIGN(sizeof(*req_hdr), MBOX_MSG_ALIGN);
+
+	for (i = 0; i < req_hdr->num_msgs; i++) {
+		msg = (struct mbox_msghdr *)((uintptr_t)mdev->mbase + offset);
+		size = mbox->rx_start + msg->next_msgoff - offset;
+
+		/* RVU_PF_FUNC_S */
+		msg->pcifunc = dev_pf_func(dev->pf, vf);
+
+		if (msg->id == MBOX_MSG_READY) {
+			struct ready_msg_rsp *rsp;
+			uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+
+			/* Handle READY message in PF */
+			dev->active_vfs[vf / max_bits] |=
+				BIT_ULL(vf % max_bits);
+			rsp = (struct ready_msg_rsp *)mbox_alloc_msg(
+				mbox, vf, sizeof(*rsp));
+			mbox_rsp_init(msg->id, rsp);
+
+			/* PF/VF function ID */
+			rsp->hdr.pcifunc = msg->pcifunc;
+			rsp->hdr.rc = 0;
+		} else {
+			struct mbox_msghdr *af_req;
+			/* Reserve AF/PF mbox message */
+			size = PLT_ALIGN(size, MBOX_MSG_ALIGN);
+			af_req = mbox_alloc_msg(dev->mbox, 0, size);
+			if (af_req == NULL)
+				return -ENOSPC;
+			mbox_req_init(msg->id, af_req);
+
+			/* Copy message from VF<->PF mbox to PF<->AF mbox */
+			mbox_memcpy((uint8_t *)af_req +
+					    sizeof(struct mbox_msghdr),
+				    (uint8_t *)msg + sizeof(struct mbox_msghdr),
+				    size - sizeof(struct mbox_msghdr));
+			af_req->pcifunc = msg->pcifunc;
+			routed++;
+		}
+		offset = mbox->rx_start + msg->next_msgoff;
+	}
+
+	if (routed > 0) {
+		plt_base_dbg("pf:%d routed %d messages from vf:%d to AF",
+			     dev->pf, routed, vf);
+		af_pf_wait_msg(dev, vf, routed);
+		mbox_reset(dev->mbox, 0);
+	}
+
+	/* Send mbox responses to VF */
+	if (mdev->num_msgs) {
+		plt_base_dbg("pf:%d reply %d messages to vf:%d", dev->pf,
+			     mdev->num_msgs, vf);
+		mbox_msg_send(mbox, vf);
+	}
+
+	return i;
+}
+
+static int
+vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
+{
+	struct mbox *mbox = &dev->mbox_vfpf_up;
+	struct mbox_dev *mdev = &mbox->dev[vf];
+	struct mbox_hdr *req_hdr;
+	struct mbox_msghdr *msg;
+	int msgs_acked = 0;
+	int offset;
+	uint16_t i;
+
+	req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
+	if (req_hdr->num_msgs == 0)
+		return 0;
+
+	offset = mbox->rx_start + PLT_ALIGN(sizeof(*req_hdr), MBOX_MSG_ALIGN);
+
+	for (i = 0; i < req_hdr->num_msgs; i++) {
+		msg = (struct mbox_msghdr *)((uintptr_t)mdev->mbase + offset);
+
+		msgs_acked++;
+		/* RVU_PF_FUNC_S */
+		msg->pcifunc = dev_pf_func(dev->pf, vf);
+
+		switch (msg->id) {
+		case MBOX_MSG_CGX_LINK_EVENT:
+			plt_base_dbg("PF: Msg 0x%x (%s) fn:0x%x (pf:%d,vf:%d)",
+				     msg->id, mbox_id2name(msg->id),
+				     msg->pcifunc, dev_get_pf(msg->pcifunc),
+				     dev_get_vf(msg->pcifunc));
+			break;
+		case MBOX_MSG_CGX_PTP_RX_INFO:
+			plt_base_dbg("PF: Msg 0x%x (%s) fn:0x%x (pf:%d,vf:%d)",
+				     msg->id, mbox_id2name(msg->id),
+				     msg->pcifunc, dev_get_pf(msg->pcifunc),
+				     dev_get_vf(msg->pcifunc));
+			break;
+		default:
+			plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+				msg->id, mbox_id2name(msg->id), msg->pcifunc);
+		}
+		offset = mbox->rx_start + msg->next_msgoff;
+	}
+	mbox_reset(mbox, vf);
+	mdev->msgs_acked = msgs_acked;
+	plt_wmb();
+
+	return i;
+}
+
+static void
+roc_vf_pf_mbox_handle_msg(void *param)
+{
+	uint16_t vf, max_vf, max_bits;
+	struct dev *dev = param;
+
+	max_bits = sizeof(dev->intr.bits[0]) * sizeof(uint64_t);
+	max_vf = max_bits * MAX_VFPF_DWORD_BITS;
+
+	for (vf = 0; vf < max_vf; vf++) {
+		if (dev->intr.bits[vf / max_bits] & BIT_ULL(vf % max_bits)) {
+			plt_base_dbg("Process vf:%d request (pf:%d, vf:%d)", vf,
+				     dev->pf, dev->vf);
+			vf_pf_process_msgs(dev, vf);
+			/* UP messages */
+			vf_pf_process_up_msgs(dev, vf);
+			dev->intr.bits[vf / max_bits] &=
+				~(BIT_ULL(vf % max_bits));
+		}
+	}
+	dev->timer_set = 0;
+}
+
+static void
+roc_vf_pf_mbox_irq(void *param)
+{
+	struct dev *dev = param;
+	bool alarm_set = false;
+	uint64_t intr;
+	int vfpf;
+
+	for (vfpf = 0; vfpf < MAX_VFPF_DWORD_BITS; ++vfpf) {
+		intr = plt_read64(dev->bar2 + RVU_PF_VFPF_MBOX_INTX(vfpf));
+		if (!intr)
+			continue;
+
+		plt_base_dbg("vfpf: %d intr: 0x%" PRIx64 " (pf:%d, vf:%d)",
+			     vfpf, intr, dev->pf, dev->vf);
+
+		/* Save and clear intr bits */
+		dev->intr.bits[vfpf] |= intr;
+		plt_write64(intr, dev->bar2 + RVU_PF_VFPF_MBOX_INTX(vfpf));
+		alarm_set = true;
+	}
+
+	if (!dev->timer_set && alarm_set) {
+		dev->timer_set = 1;
+		/* Start timer to handle messages */
+		plt_alarm_set(VF_PF_MBOX_TIMER_MS, roc_vf_pf_mbox_handle_msg,
+			      dev);
+	}
+}
+
 static void
 process_msgs(struct dev *dev, struct mbox *mbox)
 {
@@ -62,6 +393,112 @@ process_msgs(struct dev *dev, struct mbox *mbox)
 	plt_wmb();
 }
 
+/* Copies the message received from AF and sends it to VF */
+static void
+pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg)
+{
+	uint16_t max_bits = sizeof(dev->active_vfs[0]) * sizeof(uint64_t);
+	struct mbox *vf_mbox = &dev->mbox_vfpf_up;
+	struct msg_req *msg = rec_msg;
+	struct mbox_msghdr *vf_msg;
+	uint16_t vf;
+	size_t size;
+
+	size = PLT_ALIGN(mbox_id2size(msg->hdr.id), MBOX_MSG_ALIGN);
+	/* Send UP message to all VF's */
+	for (vf = 0; vf < vf_mbox->ndevs; vf++) {
+		/* VF active */
+		if (!(dev->active_vfs[vf / max_bits] & (BIT_ULL(vf))))
+			continue;
+
+		plt_base_dbg("(%s) size: %zx to VF: %d",
+			     mbox_id2name(msg->hdr.id), size, vf);
+
+		/* Reserve PF/VF mbox message */
+		vf_msg = mbox_alloc_msg(vf_mbox, vf, size);
+		if (!vf_msg) {
+			plt_err("Failed to alloc VF%d UP message", vf);
+			continue;
+		}
+		mbox_req_init(msg->hdr.id, vf_msg);
+
+		/*
+		 * Copy message from AF<->PF UP mbox
+		 * to PF<->VF UP mbox
+		 */
+		mbox_memcpy((uint8_t *)vf_msg + sizeof(struct mbox_msghdr),
+			    (uint8_t *)msg + sizeof(struct mbox_msghdr),
+			    size - sizeof(struct mbox_msghdr));
+
+		vf_msg->rc = msg->hdr.rc;
+		/* Set PF to be a sender */
+		vf_msg->pcifunc = dev->pf_func;
+
+		/* Send to VF */
+		mbox_msg_send(vf_mbox, vf);
+	}
+}
+
+static int
+mbox_up_handler_cgx_link_event(struct dev *dev, struct cgx_link_info_msg *msg,
+			       struct msg_rsp *rsp)
+{
+	struct cgx_link_user_info *linfo = &msg->link_info;
+	void *roc_nix = dev->roc_nix;
+
+	plt_base_dbg("pf:%d/vf:%d NIC Link %s --> 0x%x (%s) from: pf:%d/vf:%d",
+		     dev_get_pf(dev->pf_func), dev_get_vf(dev->pf_func),
+		     linfo->link_up ? "UP" : "DOWN", msg->hdr.id,
+		     mbox_id2name(msg->hdr.id), dev_get_pf(msg->hdr.pcifunc),
+		     dev_get_vf(msg->hdr.pcifunc));
+
+	/* PF gets link notification from AF */
+	if (dev_get_pf(msg->hdr.pcifunc) == 0) {
+		if (dev->ops && dev->ops->link_status_update)
+			dev->ops->link_status_update(roc_nix, linfo);
+
+		/* Forward the same message as received from AF to VF */
+		pf_vf_mbox_send_up_msg(dev, msg);
+	} else {
+		/* VF gets link up notification */
+		if (dev->ops && dev->ops->link_status_update)
+			dev->ops->link_status_update(roc_nix, linfo);
+	}
+
+	rsp->hdr.rc = 0;
+	return 0;
+}
+
+static int
+mbox_up_handler_cgx_ptp_rx_info(struct dev *dev,
+				struct cgx_ptp_rx_info_msg *msg,
+				struct msg_rsp *rsp)
+{
+	void *roc_nix = dev->roc_nix;
+
+	plt_base_dbg("pf:%d/vf:%d PTP mode %s --> 0x%x (%s) from: pf:%d/vf:%d",
+		     dev_get_pf(dev->pf_func), dev_get_vf(dev->pf_func),
+		     msg->ptp_en ? "ENABLED" : "DISABLED", msg->hdr.id,
+		     mbox_id2name(msg->hdr.id), dev_get_pf(msg->hdr.pcifunc),
+		     dev_get_vf(msg->hdr.pcifunc));
+
+	/* PF gets PTP notification from AF */
+	if (dev_get_pf(msg->hdr.pcifunc) == 0) {
+		if (dev->ops && dev->ops->ptp_info_update)
+			dev->ops->ptp_info_update(roc_nix, msg->ptp_en);
+
+		/* Forward the same message as received from AF to VF */
+		pf_vf_mbox_send_up_msg(dev, msg);
+	} else {
+		/* VF gets PTP notification */
+		if (dev->ops && dev->ops->ptp_info_update)
+			dev->ops->ptp_info_update(roc_nix, msg->ptp_en);
+	}
+
+	rsp->hdr.rc = 0;
+	return 0;
+}
+
 static int
 mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
 {
@@ -73,6 +510,24 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
 	default:
 		reply_invalid_msg(&dev->mbox_up, 0, 0, req->id);
 		break;
+#define M(_name, _id, _fn_name, _req_type, _rsp_type)                          \
+	case _id: {                                                            \
+		struct _rsp_type *rsp;                                         \
+		int err;                                                       \
+		rsp = (struct _rsp_type *)mbox_alloc_msg(                      \
+			&dev->mbox_up, 0, sizeof(struct _rsp_type));           \
+		if (!rsp)                                                      \
+			return -ENOMEM;                                        \
+		rsp->hdr.id = _id;                                             \
+		rsp->hdr.sig = MBOX_RSP_SIG;                                   \
+		rsp->hdr.pcifunc = dev->pf_func;                               \
+		rsp->hdr.rc = 0;                                               \
+		err = mbox_up_handler_##_fn_name(dev, (struct _req_type *)req, \
+						 rsp);                         \
+		return err;                                                    \
+	}
+		MBOX_UP_CGX_MESSAGES
+#undef M
 	}
 
 	return -ENODEV;
@@ -111,6 +566,26 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
 }
 
 static void
+roc_pf_vf_mbox_irq(void *param)
+{
+	struct dev *dev = param;
+	uint64_t intr;
+
+	intr = plt_read64(dev->bar2 + RVU_VF_INT);
+	if (intr == 0)
+		plt_base_dbg("Proceeding to check mbox UP messages if any");
+
+	plt_write64(intr, dev->bar2 + RVU_VF_INT);
+	plt_base_dbg("Irq 0x%" PRIx64 "(pf:%d,vf:%d)", intr, dev->pf, dev->vf);
+
+	/* First process all configuration messages */
+	process_msgs(dev, dev->mbox);
+
+	/* Process Uplink messages */
+	process_msgs_up(dev, &dev->mbox_up);
+}
+
+static void
 roc_af_pf_mbox_irq(void *param)
 {
 	struct dev *dev = param;
@@ -121,7 +596,7 @@ roc_af_pf_mbox_irq(void *param)
 		plt_base_dbg("Proceeding to check mbox UP messages if any");
 
 	plt_write64(intr, dev->bar2 + RVU_PF_INT);
-	plt_base_dbg("Irq 0x%" PRIx64 "(pf:%d)", intr, dev->pf);
+	plt_base_dbg("Irq 0x%" PRIx64 "(pf:%d,vf:%d)", intr, dev->pf, dev->vf);
 
 	/* First process all configuration messages */
 	process_msgs(dev, dev->mbox);
@@ -134,10 +609,33 @@ static int
 mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)
 {
 	struct plt_intr_handle *intr_handle = &pci_dev->intr_handle;
-	int rc;
+	int i, rc;
+
+	/* HW clear irq */
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; ++i)
+		plt_write64(~0ull,
+			    dev->bar2 + RVU_PF_VFPF_MBOX_INT_ENA_W1CX(i));
 
 	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1C);
 
+	dev->timer_set = 0;
+
+	/* MBOX interrupt for VF(0...63) <-> PF */
+	rc = dev_irq_register(intr_handle, roc_vf_pf_mbox_irq, dev,
+			      RVU_PF_INT_VEC_VFPF_MBOX0);
+
+	if (rc) {
+		plt_err("Fail to register PF(VF0-63) mbox irq");
+		return rc;
+	}
+	/* MBOX interrupt for VF(64...128) <-> PF */
+	rc = dev_irq_register(intr_handle, roc_vf_pf_mbox_irq, dev,
+			      RVU_PF_INT_VEC_VFPF_MBOX1);
+
+	if (rc) {
+		plt_err("Fail to register PF(VF64-128) mbox irq");
+		return rc;
+	}
 	/* MBOX interrupt AF <-> PF */
 	rc = dev_irq_register(intr_handle, roc_af_pf_mbox_irq, dev,
 			      RVU_PF_INT_VEC_AFPF_MBOX);
@@ -146,6 +644,11 @@ mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)
 		return rc;
 	}
 
+	/* HW enable intr */
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; ++i)
+		plt_write64(~0ull,
+			    dev->bar2 + RVU_PF_VFPF_MBOX_INT_ENA_W1SX(i));
+
 	plt_write64(~0ull, dev->bar2 + RVU_PF_INT);
 	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1S);
 
@@ -153,27 +656,263 @@ mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)
 }
 
 static int
+mbox_register_vf_irq(struct plt_pci_device *pci_dev, struct dev *dev)
+{
+	struct plt_intr_handle *intr_handle = &pci_dev->intr_handle;
+	int rc;
+
+	/* Clear irq */
+	plt_write64(~0ull, dev->bar2 + RVU_VF_INT_ENA_W1C);
+
+	/* MBOX interrupt PF <-> VF */
+	rc = dev_irq_register(intr_handle, roc_pf_vf_mbox_irq, dev,
+			      RVU_VF_INT_VEC_MBOX);
+	if (rc) {
+		plt_err("Fail to register PF<->VF mbox irq");
+		return rc;
+	}
+
+	/* HW enable intr */
+	plt_write64(~0ull, dev->bar2 + RVU_VF_INT);
+	plt_write64(~0ull, dev->bar2 + RVU_VF_INT_ENA_W1S);
+
+	return rc;
+}
+
+static int
 mbox_register_irq(struct plt_pci_device *pci_dev, struct dev *dev)
 {
-	return mbox_register_pf_irq(pci_dev, dev);
+	if (dev_is_vf(dev))
+		return mbox_register_vf_irq(pci_dev, dev);
+	else
+		return mbox_register_pf_irq(pci_dev, dev);
 }
 
 static void
 mbox_unregister_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)
 {
 	struct plt_intr_handle *intr_handle = &pci_dev->intr_handle;
+	int i;
+
+	/* HW clear irq */
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; ++i)
+		plt_write64(~0ull,
+			    dev->bar2 + RVU_PF_VFPF_MBOX_INT_ENA_W1CX(i));
 
 	plt_write64(~0ull, dev->bar2 + RVU_PF_INT_ENA_W1C);
 
+	dev->timer_set = 0;
+
+	plt_alarm_cancel(roc_vf_pf_mbox_handle_msg, dev);
+
+	/* Unregister the interrupt handler for each vectors */
+	/* MBOX interrupt for VF(0...63) <-> PF */
+	dev_irq_unregister(intr_handle, roc_vf_pf_mbox_irq, dev,
+			   RVU_PF_INT_VEC_VFPF_MBOX0);
+
+	/* MBOX interrupt for VF(64...128) <-> PF */
+	dev_irq_unregister(intr_handle, roc_vf_pf_mbox_irq, dev,
+			   RVU_PF_INT_VEC_VFPF_MBOX1);
+
 	/* MBOX interrupt AF <-> PF */
 	dev_irq_unregister(intr_handle, roc_af_pf_mbox_irq, dev,
 			   RVU_PF_INT_VEC_AFPF_MBOX);
 }
 
 static void
+mbox_unregister_vf_irq(struct plt_pci_device *pci_dev, struct dev *dev)
+{
+	struct plt_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	/* Clear irq */
+	plt_write64(~0ull, dev->bar2 + RVU_VF_INT_ENA_W1C);
+
+	/* Unregister the interrupt handler */
+	dev_irq_unregister(intr_handle, roc_pf_vf_mbox_irq, dev,
+			   RVU_VF_INT_VEC_MBOX);
+}
+
+static void
 mbox_unregister_irq(struct plt_pci_device *pci_dev, struct dev *dev)
 {
-	mbox_unregister_pf_irq(pci_dev, dev);
+	if (dev_is_vf(dev))
+		mbox_unregister_vf_irq(pci_dev, dev);
+	else
+		mbox_unregister_pf_irq(pci_dev, dev);
+}
+
+static int
+vf_flr_send_msg(struct dev *dev, uint16_t vf)
+{
+	struct mbox *mbox = dev->mbox;
+	struct msg_req *req;
+	int rc;
+
+	req = mbox_alloc_msg_vf_flr(mbox);
+	if (req == NULL)
+		return -ENOSPC;
+	/* Overwrite pcifunc to indicate VF */
+	req->hdr.pcifunc = dev_pf_func(dev->pf, vf);
+
+	/* Sync message in interrupt context */
+	rc = pf_af_sync_msg(dev, NULL);
+	if (rc)
+		plt_err("Failed to send VF FLR mbox msg, rc=%d", rc);
+
+	return rc;
+}
+
+static void
+roc_pf_vf_flr_irq(void *param)
+{
+	struct dev *dev = (struct dev *)param;
+	uint16_t max_vf = 64, vf;
+	uintptr_t bar2;
+	uint64_t intr;
+	int i;
+
+	max_vf = (dev->maxvf > 0) ? dev->maxvf : 64;
+	bar2 = dev->bar2;
+
+	plt_base_dbg("FLR VF interrupt: max_vf: %d", max_vf);
+
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; ++i) {
+		intr = plt_read64(bar2 + RVU_PF_VFFLR_INTX(i));
+		if (!intr)
+			continue;
+
+		for (vf = 0; vf < max_vf; vf++) {
+			if (!(intr & (1ULL << vf)))
+				continue;
+
+			plt_base_dbg("FLR: i :%d intr: 0x%" PRIx64 ", vf-%d", i,
+				     intr, (64 * i + vf));
+			/* Clear interrupt */
+			plt_write64(BIT_ULL(vf), bar2 + RVU_PF_VFFLR_INTX(i));
+			/* Disable the interrupt */
+			plt_write64(BIT_ULL(vf),
+				    bar2 + RVU_PF_VFFLR_INT_ENA_W1CX(i));
+			/* Inform AF about VF reset */
+			vf_flr_send_msg(dev, vf);
+
+			/* Signal FLR finish */
+			plt_write64(BIT_ULL(vf), bar2 + RVU_PF_VFTRPENDX(i));
+			/* Enable interrupt */
+			plt_write64(~0ull, bar2 + RVU_PF_VFFLR_INT_ENA_W1SX(i));
+		}
+	}
+}
+
+static int
+vf_flr_unregister_irqs(struct plt_pci_device *pci_dev, struct dev *dev)
+{
+	struct plt_intr_handle *intr_handle = &pci_dev->intr_handle;
+	int i;
+
+	plt_base_dbg("Unregister VF FLR interrupts for %s", pci_dev->name);
+
+	/* HW clear irq */
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; i++)
+		plt_write64(~0ull, dev->bar2 + RVU_PF_VFFLR_INT_ENA_W1CX(i));
+
+	dev_irq_unregister(intr_handle, roc_pf_vf_flr_irq, dev,
+			   RVU_PF_INT_VEC_VFFLR0);
+
+	dev_irq_unregister(intr_handle, roc_pf_vf_flr_irq, dev,
+			   RVU_PF_INT_VEC_VFFLR1);
+
+	return 0;
+}
+
+static int
+vf_flr_register_irqs(struct plt_pci_device *pci_dev, struct dev *dev)
+{
+	struct plt_intr_handle *handle = &pci_dev->intr_handle;
+	int i, rc;
+
+	plt_base_dbg("Register VF FLR interrupts for %s", pci_dev->name);
+
+	rc = dev_irq_register(handle, roc_pf_vf_flr_irq, dev,
+			      RVU_PF_INT_VEC_VFFLR0);
+	if (rc)
+		plt_err("Failed to init RVU_PF_INT_VEC_VFFLR0 rc=%d", rc);
+
+	rc = dev_irq_register(handle, roc_pf_vf_flr_irq, dev,
+			      RVU_PF_INT_VEC_VFFLR1);
+	if (rc)
+		plt_err("Failed to init RVU_PF_INT_VEC_VFFLR1 rc=%d", rc);
+
+	/* Enable HW interrupt */
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; ++i) {
+		plt_write64(~0ull, dev->bar2 + RVU_PF_VFFLR_INTX(i));
+		plt_write64(~0ull, dev->bar2 + RVU_PF_VFTRPENDX(i));
+		plt_write64(~0ull, dev->bar2 + RVU_PF_VFFLR_INT_ENA_W1SX(i));
+	}
+	return 0;
+}
+
+int
+dev_active_vfs(struct dev *dev)
+{
+	int i, count = 0;
+
+	for (i = 0; i < MAX_VFPF_DWORD_BITS; i++)
+		count += __builtin_popcount(dev->active_vfs[i]);
+
+	return count;
+}
+
+static void
+dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
+{
+	switch (pci_dev->id.device_id) {
+	case PCI_DEVID_CNXK_RVU_PF:
+		break;
+	case PCI_DEVID_CNXK_RVU_SSO_TIM_VF:
+	case PCI_DEVID_CNXK_RVU_NPA_VF:
+	case PCI_DEVID_CNXK_RVU_AF_VF:
+	case PCI_DEVID_CNXK_RVU_VF:
+	case PCI_DEVID_CNXK_RVU_SDP_VF:
+		dev->hwcap |= DEV_HWCAP_F_VF;
+		break;
+	}
+}
+
+static uintptr_t
+dev_vf_mbase_get(struct plt_pci_device *pci_dev, struct dev *dev)
+{
+	void *vf_mbase = NULL;
+	uintptr_t pa;
+
+	if (dev_is_vf(dev))
+		return 0;
+
+	/* For CN10K onwards, it is just after PF MBOX */
+	if (!roc_model_is_cn9k())
+		return dev->bar4 + MBOX_SIZE;
+
+	pa = plt_read64(dev->bar2 + RVU_PF_VF_BAR4_ADDR);
+	if (!pa) {
+		plt_err("Invalid VF mbox base pa");
+		return pa;
+	}
+
+	vf_mbase = mbox_mem_map(pa, MBOX_SIZE * pci_dev->max_vfs);
+	if (vf_mbase == MAP_FAILED) {
+		plt_err("Failed to mmap vf mbase at pa 0x%lx, rc=%d", pa,
+			errno);
+		return 0;
+	}
+	return (uintptr_t)vf_mbase;
+}
+
+static void
+dev_vf_mbase_put(struct plt_pci_device *pci_dev, uintptr_t vf_mbase)
+{
+	if (!vf_mbase || !pci_dev->max_vfs || !roc_model_is_cn9k())
+		return;
+
+	mbox_mem_unmap((void *)vf_mbase, MBOX_SIZE * pci_dev->max_vfs);
 }
 
 static uint16_t
@@ -213,7 +952,6 @@ dev_setup_shared_lmt_region(struct mbox *mbox)
 static int
 dev_lmt_setup(struct plt_pci_device *pci_dev, struct dev *dev)
 {
-	uint64_t bar4_mbox_sz = MBOX_SIZE;
 	struct idev_cfg *idev;
 	int rc;
 
@@ -237,19 +975,34 @@ dev_lmt_setup(struct plt_pci_device *pci_dev, struct dev *dev)
 			dev->pf_func, rc);
 	}
 
-	/* PF BAR4 should always be sufficient enough to
-	 * hold PF-AF MBOX + PF-VF MBOX + LMT lines.
-	 */
-	if (pci_dev->mem_resource[4].len <
-	    (bar4_mbox_sz + (RVU_LMT_LINE_MAX * RVU_LMT_SZ))) {
-		plt_err("Not enough bar4 space for lmt lines and mbox");
-		return -EFAULT;
+	if (dev_is_vf(dev)) {
+		/* VF BAR4 should always be sufficient enough to
+		 * hold LMT lines.
+		 */
+		if (pci_dev->mem_resource[4].len <
+		    (RVU_LMT_LINE_MAX * RVU_LMT_SZ)) {
+			plt_err("Not enough bar4 space for lmt lines");
+			return -EFAULT;
+		}
+
+		dev->lmt_base = dev->bar4;
+	} else {
+		uint64_t bar4_mbox_sz = MBOX_SIZE;
+
+		/* PF BAR4 should always be sufficient enough to
+		 * hold PF-AF MBOX + PF-VF MBOX + LMT lines.
+		 */
+		if (pci_dev->mem_resource[4].len <
+		    (bar4_mbox_sz + (RVU_LMT_LINE_MAX * RVU_LMT_SZ))) {
+			plt_err("Not enough bar4 space for lmt lines and mbox");
+			return -EFAULT;
+		}
+
+		/* LMT base is just after total VF MBOX area */
+		bar4_mbox_sz += (MBOX_SIZE * dev_pf_total_vfs(pci_dev));
+		dev->lmt_base = dev->bar4 + bar4_mbox_sz;
 	}
 
-	/* LMT base is just after total VF MBOX area */
-	bar4_mbox_sz += (MBOX_SIZE * dev_pf_total_vfs(pci_dev));
-	dev->lmt_base = dev->bar4 + bar4_mbox_sz;
-
 	/* Base LMT address should be chosen from only those pci funcs which
 	 * participate in LMT shared mode.
 	 */
@@ -270,6 +1023,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
 {
 	int direction, up_direction, rc;
 	uintptr_t bar2, bar4, mbox;
+	uintptr_t vf_mbase = 0;
 	uint64_t intr_offset;
 
 	bar2 = (uintptr_t)pci_dev->mem_resource[2].addr;
@@ -293,13 +1047,23 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
 		goto error;
 	}
 
+	dev->maxvf = pci_dev->max_vfs;
 	dev->bar2 = bar2;
 	dev->bar4 = bar4;
+	dev_vf_hwcap_update(pci_dev, dev);
 
-	mbox = bar4;
-	direction = MBOX_DIR_PFAF;
-	up_direction = MBOX_DIR_PFAF_UP;
-	intr_offset = RVU_PF_INT;
+	if (dev_is_vf(dev)) {
+		mbox = (roc_model_is_cn9k() ?
+			bar4 : (bar2 + RVU_VF_MBOX_REGION));
+		direction = MBOX_DIR_VFPF;
+		up_direction = MBOX_DIR_VFPF_UP;
+		intr_offset = RVU_VF_INT;
+	} else {
+		mbox = bar4;
+		direction = MBOX_DIR_PFAF;
+		up_direction = MBOX_DIR_PFAF_UP;
+		intr_offset = RVU_PF_INT;
+	}
 
 	/* Initialize the local mbox */
 	rc = mbox_init(&dev->mbox_local, mbox, bar2, direction, 1, intr_offset);
@@ -322,7 +1086,43 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
 		goto mbox_unregister;
 
 	dev->pf = dev_get_pf(dev->pf_func);
+	dev->vf = dev_get_vf(dev->pf_func);
+	memset(&dev->active_vfs, 0, sizeof(dev->active_vfs));
 
+	/* Allocate memory for device ops */
+	dev->ops = plt_zmalloc(sizeof(struct dev_ops), 0);
+	if (dev->ops == NULL) {
+		rc = -ENOMEM;
+		goto mbox_unregister;
+	}
+
+	/* Found VF devices in a PF device */
+	if (pci_dev->max_vfs > 0) {
+		/* Remap mbox area for all vf's */
+		vf_mbase = dev_vf_mbase_get(pci_dev, dev);
+		if (!vf_mbase) {
+			rc = -ENODEV;
+			goto mbox_unregister;
+		}
+		/* Init mbox object */
+		rc = mbox_init(&dev->mbox_vfpf, vf_mbase, bar2, MBOX_DIR_PFVF,
+			       pci_dev->max_vfs, intr_offset);
+		if (rc)
+			goto iounmap;
+
+		/* PF -> VF UP messages */
+		rc = mbox_init(&dev->mbox_vfpf_up, vf_mbase, bar2,
+			       MBOX_DIR_PFVF_UP, pci_dev->max_vfs, intr_offset);
+		if (rc)
+			goto iounmap;
+	}
+
+	/* Register VF-FLR irq handlers */
+	if (!dev_is_vf(dev)) {
+		rc = vf_flr_register_irqs(pci_dev, dev);
+		if (rc)
+			goto iounmap;
+	}
 	dev->mbox_active = 1;
 
 	/* Setup LMT line base */
@@ -332,8 +1132,11 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
 
 	return rc;
 iounmap:
+	dev_vf_mbase_put(pci_dev, vf_mbase);
 mbox_unregister:
 	mbox_unregister_irq(pci_dev, dev);
+	if (dev->ops)
+		plt_free(dev->ops);
 mbox_fini:
 	mbox_fini(dev->mbox);
 	mbox_fini(&dev->mbox_up);
@@ -349,6 +1152,20 @@ dev_fini(struct dev *dev, struct plt_pci_device *pci_dev)
 
 	mbox_unregister_irq(pci_dev, dev);
 
+	if (!dev_is_vf(dev))
+		vf_flr_unregister_irqs(pci_dev, dev);
+	/* Release PF - VF */
+	mbox = &dev->mbox_vfpf;
+	if (mbox->hwbase && mbox->dev)
+		dev_vf_mbase_put(pci_dev, mbox->hwbase);
+
+	if (dev->ops)
+		plt_free(dev->ops);
+
+	mbox_fini(mbox);
+	mbox = &dev->mbox_vfpf_up;
+	mbox_fini(mbox);
+
 	/* Release PF - AF */
 	mbox = dev->mbox;
 	mbox_fini(mbox);
drivers/common/cnxk/roc_dev_priv.h +42 -0

78 lines not on this page · raw message

Signature · 1 line
2.8.4
#231 lore raw

PATCH v5 10/52 common/cnxk: add base npa device support

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add base NPA device support. NPA i.e Network Pool Allocator is HW block that provides HW mempool functionality on Marvell CN9K and CN10K SoC's. NPA by providing HW mempool support, also facilitates Rx and Tx packet alloc and packet free by HW without SW intervention.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_api.h       |   3 +
 drivers/common/cnxk/roc_dev.c       |  11 ++
 drivers/common/cnxk/roc_dev_priv.h  |   6 +
 drivers/common/cnxk/roc_idev.c      |  67 ++++++++
 drivers/common/cnxk/roc_idev.h      |   3 +
 drivers/common/cnxk/roc_idev_priv.h |  12 ++
 drivers/common/cnxk/roc_npa.c       | 318 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npa.h       |  20 +++
 drivers/common/cnxk/roc_npa_priv.h  |  59 +++++++
 drivers/common/cnxk/roc_platform.c  |   1 +
 drivers/common/cnxk/roc_platform.h  |   2 +
 drivers/common/cnxk/roc_priv.h      |   3 +
 drivers/common/cnxk/roc_utils.c     |  22 +++
 drivers/common/cnxk/version.map     |   5 +
 15 files changed, 533 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npa.c
 create mode 100644 drivers/common/cnxk/roc_npa.h
 create mode 100644 drivers/common/cnxk/roc_npa_priv.h
drivers/common/cnxk/meson.build +1 -0
index 17cbc36..2aeed3e 100644
@@ -15,6 +15,7 @@ sources = files('roc_dev.c',
 		'roc_irq.c',
 		'roc_mbox.c',
 		'roc_model.c',
+		'roc_npa.c',
 		'roc_platform.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_api.h +3 -0
index 27ddc3a..9289c68 100644
@@ -79,6 +79,9 @@
 /* Mbox */
 #include "roc_mbox.h"
 
+/* NPA */
+#include "roc_npa.h"
+
 /* Utils */
 #include "roc_utils.h"
 
drivers/common/cnxk/roc_dev.c +11 -0
index 4cd5978..a39acc9 100644
@@ -1125,6 +1125,10 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
 	}
 	dev->mbox_active = 1;
 
+	rc = npa_lf_init(dev, pci_dev);
+	if (rc)
+		goto iounmap;
+
 	/* Setup LMT line base */
 	rc = dev_lmt_setup(pci_dev, dev);
 	if (rc)
@@ -1150,6 +1154,13 @@ dev_fini(struct dev *dev, struct plt_pci_device *pci_dev)
 	struct plt_intr_handle *intr_handle = &pci_dev->intr_handle;
 	struct mbox *mbox;
 
+	/* Check if this dev hosts npalf and has 1+ refs */
+	if (idev_npa_lf_active(dev) > 1)
+		return -EAGAIN;
+
+	/* Clear references to this pci dev */
+	npa_lf_fini();
+
 	mbox_unregister_irq(pci_dev, dev);
 
 	if (!dev_is_vf(dev))
drivers/common/cnxk/roc_dev_priv.h +6 -0
index d20b089..910cfb6 100644
@@ -78,6 +78,7 @@ struct dev {
 	dev_intr_t intr;
 	int timer_set; /* ~0 : no alarm handling */
 	uint64_t hwcap;
+	struct npa_lf npa;
 	struct mbox *mbox;
 	uint16_t maxvf;
 	struct dev_ops *ops;
@@ -85,6 +86,11 @@ struct dev {
 	bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
 } __plt_cache_aligned;
 
+struct npa {
+	struct plt_pci_device *pci_dev;
+	struct dev dev;
+} __plt_cache_aligned;
+
 extern uint16_t dev_rclk_freq;
 extern uint16_t dev_sclk_freq;
 
drivers/common/cnxk/roc_idev.c +67 -0

76 lines not on this page · raw message

drivers/common/cnxk/roc_idev.h +3 -0
index dff0741..f267865 100644
@@ -5,6 +5,9 @@
 #ifndef _ROC_IDEV_H_
 #define _ROC_IDEV_H_
 
+uint32_t __roc_api roc_idev_npa_maxpools_get(void);
+void __roc_api roc_idev_npa_maxpools_set(uint32_t max_pools);
+
 /* LMT */
 uint64_t __roc_api roc_idev_lmt_base_addr_get(void);
 uint16_t __roc_api roc_idev_num_lmtlines_get(void);
drivers/common/cnxk/roc_idev_priv.h +12 -0
index a096288..36cdb33 100644
@@ -6,7 +6,12 @@
 #define _ROC_IDEV_PRIV_H_
 
 /* Intra device related functions */
+struct npa_lf;
 struct idev_cfg {
+	uint16_t npa_pf_func;
+	struct npa_lf *npa;
+	uint16_t npa_refcnt;
+	uint32_t max_pools;
 	uint16_t lmt_pf_func;
 	uint16_t num_lmtlines;
 	uint64_t lmt_base_addr;
@@ -16,6 +21,13 @@ struct idev_cfg {
 struct idev_cfg *idev_get_cfg(void);
 void idev_set_defaults(struct idev_cfg *idev);
 
+/* idev npa */
+uint16_t idev_npa_pffunc_get(void);
+struct npa_lf *idev_npa_obj_get(void);
+uint32_t idev_npa_maxpools_get(void);
+void idev_npa_maxpools_set(uint32_t max_pools);
+uint16_t idev_npa_lf_active(struct dev *dev);
+
 /* idev lmt */
 uint16_t idev_lmt_pffunc_get(void);
 
drivers/common/cnxk/roc_npa.c new file +318 -0

318 lines not on this page · raw message

drivers/common/cnxk/roc_npa.h new file +20 -0
new file mode 100644
index 0000000..a708725
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _ROC_NPA_H_
+#define _ROC_NPA_H_
+
+#define ROC_AURA_ID_MASK       (BIT_ULL(16) - 1)
+
+struct roc_npa {
+	struct plt_pci_device *pci_dev;
+
+#define ROC_NPA_MEM_SZ (1 * 1024)
+	uint8_t reserved[ROC_NPA_MEM_SZ] __plt_cache_aligned;
+} __plt_cache_aligned;
+
+int __roc_api roc_npa_dev_init(struct roc_npa *roc_npa);
+int __roc_api roc_npa_dev_fini(struct roc_npa *roc_npa);
+
+#endif /* _ROC_NPA_H_ */
drivers/common/cnxk/roc_npa_priv.h new file +59 -0

59 lines not on this page · raw message

drivers/common/cnxk/roc_platform.c +1 -0
index 4147f59..444d223 100644
@@ -58,3 +58,4 @@ roc_plt_init(void)
 
 RTE_LOG_REGISTER(cnxk_logtype_base, pmd.cnxk.base, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_mbox, pmd.cnxk.mbox, NOTICE);
+RTE_LOG_REGISTER(cnxk_logtype_npa, pmd.mempool.cnxk, NOTICE);
drivers/common/cnxk/roc_platform.h +2 -0
index 84c2da4..69ec600 100644
@@ -134,6 +134,7 @@
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
+extern int cnxk_logtype_npa;
 
 #define plt_err(fmt, args...)                                                  \
 	RTE_LOG(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
@@ -151,6 +152,7 @@ extern int cnxk_logtype_mbox;
 
 #define plt_base_dbg(fmt, ...)	plt_dbg(base, fmt, ##__VA_ARGS__)
 #define plt_mbox_dbg(fmt, ...)	plt_dbg(mbox, fmt, ##__VA_ARGS__)
+#define plt_npa_dbg(fmt, ...)	plt_dbg(npa, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)				\
drivers/common/cnxk/roc_priv.h +3 -0
index 2df2d66..21599dc 100644
@@ -11,6 +11,9 @@
 /* Mbox */
 #include "roc_mbox_priv.h"
 
+/* NPA */
+#include "roc_npa_priv.h"
+
 /* Dev */
 #include "roc_dev_priv.h"
 
drivers/common/cnxk/roc_utils.c +22 -0
index b21064a..b5d8f0b 100644
@@ -11,9 +11,31 @@ roc_error_msg_get(int errorcode)
 	const char *err_msg;
 
 	switch (errorcode) {
+	case NPA_ERR_PARAM:
 	case UTIL_ERR_PARAM:
 		err_msg = "Invalid parameter";
 		break;
+	case NPA_ERR_ALLOC:
+		err_msg = "NPA alloc failed";
+		break;
+	case NPA_ERR_INVALID_BLOCK_SZ:
+		err_msg = "NPA invalid block size";
+		break;
+	case NPA_ERR_AURA_ID_ALLOC:
+		err_msg = "NPA aura id alloc failed";
+		break;
+	case NPA_ERR_AURA_POOL_INIT:
+		err_msg = "NPA aura pool init failed";
+		break;
+	case NPA_ERR_AURA_POOL_FINI:
+		err_msg = "NPA aura pool fini failed";
+		break;
+	case NPA_ERR_BASE_INVALID:
+		err_msg = "NPA invalid base";
+		break;
+	case NPA_ERR_DEVICE_NOT_BOUNDED:
+		err_msg = "NPA device is not bounded";
+		break;
 	case UTIL_ERR_FS:
 		err_msg = "file operation failed";
 		break;
drivers/common/cnxk/version.map +5 -0
index 369cff3..04a0d33 100644
@@ -3,11 +3,16 @@ INTERNAL {
 
 	cnxk_logtype_base;
 	cnxk_logtype_mbox;
+	cnxk_logtype_npa;
 	roc_clk_freq_get;
 	roc_error_msg_get;
 	roc_idev_lmt_base_addr_get;
+	roc_idev_npa_maxpools_get;
+	roc_idev_npa_maxpools_set;
 	roc_idev_num_lmtlines_get;
 	roc_model;
+	roc_npa_dev_fini;
+	roc_npa_dev_init;
 	roc_plt_init;
 	roc_plt_init_cb_register;
 
Signature · 1 line
2.8.4
#232 lore raw

PATCH v5 11/52 common/cnxk: add npa irq support

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add support for NPA IRQs.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_npa.c      |   7 +
 drivers/common/cnxk/roc_npa_irq.c  | 297 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npa_priv.h |   4 +
 4 files changed, 309 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npa_irq.c
drivers/common/cnxk/meson.build +1 -0
index 2aeed3e..f8b777a 100644
@@ -16,6 +16,7 @@ sources = files('roc_dev.c',
 		'roc_mbox.c',
 		'roc_model.c',
 		'roc_npa.c',
+		'roc_npa_irq.c',
 		'roc_platform.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_npa.c +7 -0
index 2aa726b..0d4a56a 100644
@@ -242,11 +242,17 @@ npa_lf_init(struct dev *dev, struct plt_pci_device *pci_dev)
 	idev->npa = lf;
 	plt_wmb();
 
+	rc = npa_register_irqs(lf);
+	if (rc)
+		goto npa_fini;
+
 	plt_npa_dbg("npa=%p max_pools=%d pf_func=0x%x msix=0x%x", lf,
 		    roc_idev_npa_maxpools_get(), lf->pf_func, npa_msixoff);
 
 	return 0;
 
+npa_fini:
+	npa_dev_fini(idev->npa);
 npa_detach:
 	npa_detach(dev->mbox);
 fail:
@@ -268,6 +274,7 @@ npa_lf_fini(void)
 	if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
 		return 0;
 
+	npa_unregister_irqs(idev->npa);
 	rc |= npa_dev_fini(idev->npa);
 	rc |= npa_detach(idev->npa->mbox);
 	idev_set_defaults(idev);
drivers/common/cnxk/roc_npa_irq.c new file +297 -0

297 lines not on this page · raw message

drivers/common/cnxk/roc_npa_priv.h +4 -0
index dd6981f..5a02a61 100644
@@ -56,4 +56,8 @@ roc_npa_to_npa_priv(struct roc_npa *roc_npa)
 int npa_lf_init(struct dev *dev, struct plt_pci_device *pci_dev);
 int npa_lf_fini(void);
 
+/* IRQ */
+int npa_register_irqs(struct npa_lf *lf);
+void npa_unregister_irqs(struct npa_lf *lf);
+
 #endif /* _ROC_NPA_PRIV_H_ */
Signature · 1 line
2.8.4
#233 lore raw

PATCH v5 12/52 common/cnxk: add npa debug support

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add NPA debug APIs.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_npa.h       |   4 +
 drivers/common/cnxk/roc_npa_debug.c | 184 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npa_irq.c   |   1 +
 drivers/common/cnxk/version.map     |   2 +
 5 files changed, 192 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npa_debug.c
drivers/common/cnxk/meson.build +1 -0
index f8b777a..01a8f80 100644
@@ -16,6 +16,7 @@ sources = files('roc_dev.c',
 		'roc_mbox.c',
 		'roc_model.c',
 		'roc_npa.c',
+		'roc_npa_debug.c',
 		'roc_npa_irq.c',
 		'roc_platform.c',
 		'roc_utils.c')
drivers/common/cnxk/roc_npa.h +4 -0
index a708725..029f966 100644
@@ -17,4 +17,8 @@ struct roc_npa {
 int __roc_api roc_npa_dev_init(struct roc_npa *roc_npa);
 int __roc_api roc_npa_dev_fini(struct roc_npa *roc_npa);
 
+/* Debug */
+int __roc_api roc_npa_ctx_dump(void);
+int __roc_api roc_npa_dump(void);
+
 #endif /* _ROC_NPA_H_ */
drivers/common/cnxk/roc_npa_debug.c new file +184 -0

184 lines not on this page · raw message

drivers/common/cnxk/roc_npa_irq.c +1 -0
index 2d1e535..0a19319 100644
@@ -192,6 +192,7 @@ npa_q_irq(void *param)
 
 	/* Clear interrupt */
 	plt_write64(intr, lf->base + NPA_LF_QINTX_INT(qintx));
+	roc_npa_ctx_dump();
 }
 
 static int
drivers/common/cnxk/version.map +2 -0
index 04a0d33..41752d9 100644
@@ -11,8 +11,10 @@ INTERNAL {
 	roc_idev_npa_maxpools_set;
 	roc_idev_num_lmtlines_get;
 	roc_model;
+	roc_npa_ctx_dump;
 	roc_npa_dev_fini;
 	roc_npa_dev_init;
+	roc_npa_dump;
 	roc_plt_init;
 	roc_plt_init_cb_register;
 
Signature · 1 line
2.8.4
#234 lore raw

PATCH v5 13/52 common/cnxk: add npa pool HW ops

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add APIs for creating, destroying, modifying
NPA pools.

---
 drivers/common/cnxk/roc_npa.c   | 421 ++++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npa.h   | 146 ++++++++++++++
 drivers/common/cnxk/version.map |   5 +
 3 files changed, 572 insertions(+)
drivers/common/cnxk/roc_npa.c +421 -0
index 0d4a56a..80f5a78 100644
@@ -5,6 +5,427 @@
 #include "roc_api.h"
 #include "roc_priv.h"
 
+void
+roc_npa_aura_op_range_set(uint64_t aura_handle, uint64_t start_iova,
+			  uint64_t end_iova)
+{
+	const uint64_t start = roc_npa_aura_handle_to_base(aura_handle) +
+			       NPA_LF_POOL_OP_PTR_START0;
+	const uint64_t end = roc_npa_aura_handle_to_base(aura_handle) +
+			     NPA_LF_POOL_OP_PTR_END0;
+	uint64_t reg = roc_npa_aura_handle_to_aura(aura_handle);
+	struct npa_lf *lf = idev_npa_obj_get();
+	struct npa_aura_lim *lim;
+
+	PLT_ASSERT(lf);
+	lim = lf->aura_lim;
+
+	lim[reg].ptr_start = PLT_MIN(lim[reg].ptr_start, start_iova);
+	lim[reg].ptr_end = PLT_MAX(lim[reg].ptr_end, end_iova);
+
+	roc_store_pair(lim[reg].ptr_start, reg, start);
+	roc_store_pair(lim[reg].ptr_end, reg, end);
+}
+
+static int
+npa_aura_pool_init(struct mbox *mbox, uint32_t aura_id, struct npa_aura_s *aura,
+		   struct npa_pool_s *pool)
+{
+	struct npa_aq_enq_req *aura_init_req, *pool_init_req;
+	struct npa_aq_enq_rsp *aura_init_rsp, *pool_init_rsp;
+	struct mbox_dev *mdev = &mbox->dev[0];
+	int rc = -ENOSPC, off;
+
+	aura_init_req = mbox_alloc_msg_npa_aq_enq(mbox);
+	if (aura_init_req == NULL)
+		return rc;
+	aura_init_req->aura_id = aura_id;
+	aura_init_req->ctype = NPA_AQ_CTYPE_AURA;
+	aura_init_req->op = NPA_AQ_INSTOP_INIT;
+	mbox_memcpy(&aura_init_req->aura, aura, sizeof(*aura));
+
+	pool_init_req = mbox_alloc_msg_npa_aq_enq(mbox);
+	if (pool_init_req == NULL)
+		return rc;
+	pool_init_req->aura_id = aura_id;
+	pool_init_req->ctype = NPA_AQ_CTYPE_POOL;
+	pool_init_req->op = NPA_AQ_INSTOP_INIT;
+	mbox_memcpy(&pool_init_req->pool, pool, sizeof(*pool));
+
+	rc = mbox_process(mbox);
+	if (rc < 0)
+		return rc;
+
+	off = mbox->rx_start +
+	      PLT_ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
+	aura_init_rsp = (struct npa_aq_enq_rsp *)((uintptr_t)mdev->mbase + off);
+	off = mbox->rx_start + aura_init_rsp->hdr.next_msgoff;
+	pool_init_rsp = (struct npa_aq_enq_rsp *)((uintptr_t)mdev->mbase + off);
+
+	if (aura_init_rsp->hdr.rc == 0 && pool_init_rsp->hdr.rc == 0)
+		return 0;
+	else
+		return NPA_ERR_AURA_POOL_INIT;
+}
+
+static int
+npa_aura_pool_fini(struct mbox *mbox, uint32_t aura_id, uint64_t aura_handle)
+{
+	struct npa_aq_enq_req *aura_req, *pool_req;
+	struct npa_aq_enq_rsp *aura_rsp, *pool_rsp;
+	struct mbox_dev *mdev = &mbox->dev[0];
+	struct ndc_sync_op *ndc_req;
+	int rc = -ENOSPC, off;
+	uint64_t ptr;
+
+	/* Procedure for disabling an aura/pool */
+	plt_delay_us(10);
+
+	/* Clear all the pointers from the aura */
+	do {
+		ptr = roc_npa_aura_op_alloc(aura_handle, 0);
+	} while (ptr);
+
+	pool_req = mbox_alloc_msg_npa_aq_enq(mbox);
+	if (pool_req == NULL)
+		return rc;
+	pool_req->aura_id = aura_id;
+	pool_req->ctype = NPA_AQ_CTYPE_POOL;
+	pool_req->op = NPA_AQ_INSTOP_WRITE;
+	pool_req->pool.ena = 0;
+	pool_req->pool_mask.ena = ~pool_req->pool_mask.ena;
+
+	aura_req = mbox_alloc_msg_npa_aq_enq(mbox);
+	if (aura_req == NULL)
+		return rc;
+	aura_req->aura_id = aura_id;
+	aura_req->ctype = NPA_AQ_CTYPE_AURA;
+	aura_req->op = NPA_AQ_INSTOP_WRITE;
+	aura_req->aura.ena = 0;
+	aura_req->aura_mask.ena = ~aura_req->aura_mask.ena;
+
+	rc = mbox_process(mbox);
+	if (rc < 0)
+		return rc;
+
+	off = mbox->rx_start +
+	      PLT_ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
+	pool_rsp = (struct npa_aq_enq_rsp *)((uintptr_t)mdev->mbase + off);
+
+	off = mbox->rx_start + pool_rsp->hdr.next_msgoff;
+	aura_rsp = (struct npa_aq_enq_rsp *)((uintptr_t)mdev->mbase + off);
+
+	if (aura_rsp->hdr.rc != 0 || pool_rsp->hdr.rc != 0)
+		return NPA_ERR_AURA_POOL_FINI;
+
+	/* Sync NDC-NPA for LF */
+	ndc_req = mbox_alloc_msg_ndc_sync_op(mbox);
+	if (ndc_req == NULL)
+		return -ENOSPC;
+	ndc_req->npa_lf_sync = 1;
+	rc = mbox_process(mbox);
+	if (rc) {
+		plt_err("Error on NDC-NPA LF sync, rc %d", rc);
+		return NPA_ERR_AURA_POOL_FINI;
+	}
+	return 0;
+}
+
+static inline char *
+npa_stack_memzone_name(struct npa_lf *lf, int pool_id, char *name)
+{
+	snprintf(name, PLT_MEMZONE_NAMESIZE, "roc_npa_stack_%x_%d", lf->pf_func,
+		 pool_id);
+	return name;
+}
+
+static inline const struct plt_memzone *
+npa_stack_dma_alloc(struct npa_lf *lf, char *name, int pool_id, size_t size)
+{
+	const char *mz_name = npa_stack_memzone_name(lf, pool_id, name);
+
+	return plt_memzone_reserve_cache_align(mz_name, size);
+}
+
+static inline int
+npa_stack_dma_free(struct npa_lf *lf, char *name, int pool_id)
+{
+	const struct plt_memzone *mz;
+
+	mz = plt_memzone_lookup(npa_stack_memzone_name(lf, pool_id, name));
+	if (mz == NULL)
+		return NPA_ERR_PARAM;
+
+	return plt_memzone_free(mz);
+}
+
+static inline int
+bitmap_ctzll(uint64_t slab)
+{
+	if (slab == 0)
+		return 0;
+
+	return __builtin_ctzll(slab);
+}
+
+static int
+npa_aura_pool_pair_alloc(struct npa_lf *lf, const uint32_t block_size,
+			 const uint32_t block_count, struct npa_aura_s *aura,
+			 struct npa_pool_s *pool, uint64_t *aura_handle)
+{
+	int rc, aura_id, pool_id, stack_size, alloc_size;
+	char name[PLT_MEMZONE_NAMESIZE];
+	const struct plt_memzone *mz;
+	uint64_t slab;
+	uint32_t pos;
+
+	/* Sanity check */
+	if (!lf || !block_size || !block_count || !pool || !aura ||
+	    !aura_handle)
+		return NPA_ERR_PARAM;
+
+	/* Block size should be cache line aligned and in range of 128B-128KB */
+	if (block_size % ROC_ALIGN || block_size < 128 ||
+	    block_size > 128 * 1024)
+		return NPA_ERR_INVALID_BLOCK_SZ;
+
+	pos = 0;
+	slab = 0;
+	/* Scan from the beginning */
+	plt_bitmap_scan_init(lf->npa_bmp);
+	/* Scan bitmap to get the free pool */
+	rc = plt_bitmap_scan(lf->npa_bmp, &pos, &slab);
+	/* Empty bitmap */
+	if (rc == 0) {
+		plt_err("Mempools exhausted");
+		return NPA_ERR_AURA_ID_ALLOC;
+	}
+
+	/* Get aura_id from resource bitmap */
+	aura_id = pos + bitmap_ctzll(slab);
+	/* Mark pool as reserved */
+	plt_bitmap_clear(lf->npa_bmp, aura_id);
+
+	/* Configuration based on each aura has separate pool(aura-pool pair) */
+	pool_id = aura_id;
+	rc = (aura_id < 0 || pool_id >= (int)lf->nr_pools ||
+	      aura_id >= (int)BIT_ULL(6 + lf->aura_sz)) ?
+			   NPA_ERR_AURA_ID_ALLOC :
+			   0;
+	if (rc)
+		goto exit;
+
+	/* Allocate stack memory */
+	stack_size = (block_count + lf->stack_pg_ptrs - 1) / lf->stack_pg_ptrs;
+	alloc_size = stack_size * lf->stack_pg_bytes;
+
+	mz = npa_stack_dma_alloc(lf, name, pool_id, alloc_size);
+	if (mz == NULL) {
+		rc = NPA_ERR_ALLOC;
+		goto aura_res_put;
+	}
+
+	/* Update aura fields */
+	aura->pool_addr = pool_id; /* AF will translate to associated poolctx */
+	aura->ena = 1;
+	aura->shift = __builtin_clz(block_count) - 8;
+	aura->limit = block_count;
+	aura->pool_caching = 1;
+	aura->err_int_ena = BIT(NPA_AURA_ERR_INT_AURA_ADD_OVER);
+	aura->err_int_ena |= BIT(NPA_AURA_ERR_INT_AURA_ADD_UNDER);
+	aura->err_int_ena |= BIT(NPA_AURA_ERR_INT_AURA_FREE_UNDER);
+	aura->err_int_ena |= BIT(NPA_AURA_ERR_INT_POOL_DIS);
+	/* Many to one reduction */
+	aura->err_qint_idx = aura_id % lf->qints;
+
+	/* Update pool fields */
+	pool->stack_base = mz->iova;
+	pool->ena = 1;
+	pool->buf_size = block_size / ROC_ALIGN;
+	pool->stack_max_pages = stack_size;
+	pool->shift = __builtin_clz(block_count) - 8;
+	pool->ptr_start = 0;
+	pool->ptr_end = ~0;
+	pool->stack_caching = 1;
+	pool->err_int_ena = BIT(NPA_POOL_ERR_INT_OVFLS);
+	pool->err_int_ena |= BIT(NPA_POOL_ERR_INT_RANGE);
+	pool->err_int_ena |= BIT(NPA_POOL_ERR_INT_PERR);
+
+	/* Many to one reduction */
+	pool->err_qint_idx = pool_id % lf->qints;
+
+	/* Issue AURA_INIT and POOL_INIT op */
+	rc = npa_aura_pool_init(lf->mbox, aura_id, aura, pool);
+	if (rc)
+		goto stack_mem_free;
+
+	*aura_handle = roc_npa_aura_handle_gen(aura_id, lf->base);
+	/* Update aura count */
+	roc_npa_aura_op_cnt_set(*aura_handle, 0, block_count);
+	/* Read it back to make sure aura count is updated */
+	roc_npa_aura_op_cnt_get(*aura_handle);
+
+	return 0;
+
+stack_mem_free:
+	plt_memzone_free(mz);
+aura_res_put:
+	plt_bitmap_set(lf->npa_bmp, aura_id);
+exit:
+	return rc;
+}
+
+int
+roc_npa_pool_create(uint64_t *aura_handle, uint32_t block_size,
+		    uint32_t block_count, struct npa_aura_s *aura,
+		    struct npa_pool_s *pool)
+{
+	struct npa_aura_s defaura;
+	struct npa_pool_s defpool;
+	struct idev_cfg *idev;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL) {
+		rc = NPA_ERR_DEVICE_NOT_BOUNDED;
+		goto error;
+	}
+
+	idev = idev_get_cfg();
+	if (idev == NULL) {
+		rc = NPA_ERR_ALLOC;
+		goto error;
+	}
+
+	if (aura == NULL) {
+		memset(&defaura, 0, sizeof(struct npa_aura_s));
+		aura = &defaura;
+	}
+	if (pool == NULL) {
+		memset(&defpool, 0, sizeof(struct npa_pool_s));
+		defpool.nat_align = 1;
+		defpool.buf_offset = 1;
+		pool = &defpool;
+	}
+
+	rc = npa_aura_pool_pair_alloc(lf, block_size, block_count, aura, pool,
+				      aura_handle);
+	if (rc) {
+		plt_err("Failed to alloc pool or aura rc=%d", rc);
+		goto error;
+	}
+
+	plt_npa_dbg("lf=%p block_sz=%d block_count=%d aura_handle=0x%" PRIx64,
+		    lf, block_size, block_count, *aura_handle);
+
+	/* Just hold the reference of the object */
+	__atomic_fetch_add(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST);
+error:
+	return rc;
+}
+
+int
+roc_npa_aura_limit_modify(uint64_t aura_handle, uint16_t aura_limit)
+{
+	struct npa_aq_enq_req *aura_req;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	aura_req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (aura_req == NULL)
+		return -ENOMEM;
+	aura_req->aura_id = roc_npa_aura_handle_to_aura(aura_handle);
+	aura_req->ctype = NPA_AQ_CTYPE_AURA;
+	aura_req->op = NPA_AQ_INSTOP_WRITE;
+
+	aura_req->aura.limit = aura_limit;
+	aura_req->aura_mask.limit = ~(aura_req->aura_mask.limit);
+	rc = mbox_process(lf->mbox);
+
+	return rc;
+}
+
+static int
+npa_aura_pool_pair_free(struct npa_lf *lf, uint64_t aura_handle)
+{
+	char name[PLT_MEMZONE_NAMESIZE];
+	int aura_id, pool_id, rc;
+
+	if (!lf || !aura_handle)
+		return NPA_ERR_PARAM;
+
+	aura_id = roc_npa_aura_handle_to_aura(aura_handle);
+	pool_id = aura_id;
+	rc = npa_aura_pool_fini(lf->mbox, aura_id, aura_handle);
+	rc |= npa_stack_dma_free(lf, name, pool_id);
+
+	plt_bitmap_set(lf->npa_bmp, aura_id);
+
+	return rc;
+}
+
+int
+roc_npa_pool_destroy(uint64_t aura_handle)
+{
+	struct npa_lf *lf = idev_npa_obj_get();
+	int rc = 0;
+
+	plt_npa_dbg("lf=%p aura_handle=0x%" PRIx64, lf, aura_handle);
+	rc = npa_aura_pool_pair_free(lf, aura_handle);
+	if (rc)
+		plt_err("Failed to destroy pool or aura rc=%d", rc);
+
+	/* Release the reference of npa */
+	rc |= npa_lf_fini();
+	return rc;
+}
+
+int
+roc_npa_pool_range_update_check(uint64_t aura_handle)
+{
+	uint64_t aura_id = roc_npa_aura_handle_to_aura(aura_handle);
+	struct npa_lf *lf;
+	struct npa_aura_lim *lim;
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_PARAM;
+
+	lim = lf->aura_lim;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (req == NULL)
+		return -ENOSPC;
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(0x%" PRIx64 ") context", aura_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	if (lim[aura_id].ptr_start != pool->ptr_start ||
+	    lim[aura_id].ptr_end != pool->ptr_end) {
+		plt_err("Range update failed on pool(0x%" PRIx64 ")", aura_id);
+		return NPA_ERR_PARAM;
+	}
+
+	return 0;
+}
+
 static inline int
 npa_attach(struct mbox *mbox)
 {
drivers/common/cnxk/roc_npa.h +146 -0

158 lines not on this page · raw message

drivers/common/cnxk/version.map +5 -0
index 41752d9..1250767 100644
@@ -11,10 +11,15 @@ INTERNAL {
 	roc_idev_npa_maxpools_set;
 	roc_idev_num_lmtlines_get;
 	roc_model;
+	roc_npa_aura_limit_modify;
+	roc_npa_aura_op_range_set;
 	roc_npa_ctx_dump;
 	roc_npa_dev_fini;
 	roc_npa_dev_init;
 	roc_npa_dump;
+	roc_npa_pool_create;
+	roc_npa_pool_destroy;
+	roc_npa_pool_range_update_check;
 	roc_plt_init;
 	roc_plt_init_cb_register;
 
Signature · 1 line
2.8.4
#235 lore raw

PATCH v5 14/52 common/cnxk: add npa bulk alloc/free support

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add APIs to alloc/free in bulk from NPA pool.

---
 drivers/common/cnxk/roc_npa.h | 229 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 229 insertions(+)
drivers/common/cnxk/roc_npa.h +229 -0
index 6983849..b829b23 100644
@@ -8,6 +8,11 @@
 #define ROC_AURA_ID_MASK       (BIT_ULL(16) - 1)
 #define ROC_AURA_OP_LIMIT_MASK (BIT_ULL(36) - 1)
 
+/* 16 CASP instructions can be outstanding in CN9k, but we use only 15
+ * outstanding CASPs as we run out of registers.
+ */
+#define ROC_CN9K_NPA_BULK_ALLOC_MAX_PTRS 30
+
 /*
  * Generate 64bit handle to have optimized alloc and free aura operation.
  * 0 - ROC_AURA_ID_MASK for storing the aura_id.
@@ -141,6 +146,230 @@ roc_npa_aura_op_available(uint64_t aura_handle)
 		return reg & 0xFFFFFFFFF;
 }
 
+static inline void
+roc_npa_aura_op_bulk_free(uint64_t aura_handle, uint64_t const *buf,
+			  unsigned int num, const int fabs)
+{
+	unsigned int i;
+
+	for (i = 0; i < num; i++) {
+		const uint64_t inbuf = buf[i];
+
+		roc_npa_aura_op_free(aura_handle, fabs, inbuf);
+	}
+}
+
+static inline unsigned int
+roc_npa_aura_bulk_alloc(uint64_t aura_handle, uint64_t *buf, unsigned int num,
+			const int drop)
+{
+#if defined(__aarch64__)
+	uint64_t wdata = roc_npa_aura_handle_to_aura(aura_handle);
+	unsigned int i, count;
+	uint64_t addr;
+
+	if (drop)
+		wdata |= BIT_ULL(63); /* DROP */
+
+	addr = roc_npa_aura_handle_to_base(aura_handle) +
+	       NPA_LF_AURA_OP_ALLOCX(0);
+
+	switch (num) {
+	case 30:
+		asm volatile(
+			".cpu  generic+lse\n"
+			"mov v18.d[0], %[dst]\n"
+			"mov v18.d[1], %[loc]\n"
+			"mov v19.d[0], %[wdata]\n"
+			"mov v19.d[1], x30\n"
+			"mov v20.d[0], x24\n"
+			"mov v20.d[1], x25\n"
+			"mov v21.d[0], x26\n"
+			"mov v21.d[1], x27\n"
+			"mov v22.d[0], x28\n"
+			"mov v22.d[1], x29\n"
+			"mov x28, v19.d[0]\n"
+			"mov x29, v19.d[0]\n"
+			"mov x30, v18.d[1]\n"
+			"casp x0, x1, x28, x29, [x30]\n"
+			"casp x2, x3, x28, x29, [x30]\n"
+			"casp x4, x5, x28, x29, [x30]\n"
+			"casp x6, x7, x28, x29, [x30]\n"
+			"casp x8, x9, x28, x29, [x30]\n"
+			"casp x10, x11, x28, x29, [x30]\n"
+			"casp x12, x13, x28, x29, [x30]\n"
+			"casp x14, x15, x28, x29, [x30]\n"
+			"casp x16, x17, x28, x29, [x30]\n"
+			"casp x18, x19, x28, x29, [x30]\n"
+			"casp x20, x21, x28, x29, [x30]\n"
+			"casp x22, x23, x28, x29, [x30]\n"
+			"casp x24, x25, x28, x29, [x30]\n"
+			"casp x26, x27, x28, x29, [x30]\n"
+			"casp x28, x29, x28, x29, [x30]\n"
+			"mov x30, v18.d[0]\n"
+			"stp x0, x1, [x30]\n"
+			"stp x2, x3, [x30, #16]\n"
+			"stp x4, x5, [x30, #32]\n"
+			"stp x6, x7, [x30, #48]\n"
+			"stp x8, x9, [x30, #64]\n"
+			"stp x10, x11, [x30, #80]\n"
+			"stp x12, x13, [x30, #96]\n"
+			"stp x14, x15, [x30, #112]\n"
+			"stp x16, x17, [x30, #128]\n"
+			"stp x18, x19, [x30, #144]\n"
+			"stp x20, x21, [x30, #160]\n"
+			"stp x22, x23, [x30, #176]\n"
+			"stp x24, x25, [x30, #192]\n"
+			"stp x26, x27, [x30, #208]\n"
+			"stp x28, x29, [x30, #224]\n"
+			"mov %[dst], v18.d[0]\n"
+			"mov %[loc], v18.d[1]\n"
+			"mov %[wdata], v19.d[0]\n"
+			"mov x30, v19.d[1]\n"
+			"mov x24, v20.d[0]\n"
+			"mov x25, v20.d[1]\n"
+			"mov x26, v21.d[0]\n"
+			"mov x27, v21.d[1]\n"
+			"mov x28, v22.d[0]\n"
+			"mov x29, v22.d[1]\n"
+			:
+			: [wdata] "r"(wdata), [loc] "r"(addr), [dst] "r"(buf)
+			: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6",
+			  "x7", "x8", "x9", "x10", "x11", "x12", "x13", "x14",
+			  "x15", "x16", "x17", "x18", "x19", "x20", "x21",
+			  "x22", "x23", "v18", "v19", "v20", "v21", "v22");
+		break;
+	case 16:
+		asm volatile(
+			".cpu  generic+lse\n"
+			"mov x16, %[wdata]\n"
+			"mov x17, %[wdata]\n"
+			"casp x0, x1, x16, x17, [%[loc]]\n"
+			"casp x2, x3, x16, x17, [%[loc]]\n"
+			"casp x4, x5, x16, x17, [%[loc]]\n"
+			"casp x6, x7, x16, x17, [%[loc]]\n"
+			"casp x8, x9, x16, x17, [%[loc]]\n"
+			"casp x10, x11, x16, x17, [%[loc]]\n"
+			"casp x12, x13, x16, x17, [%[loc]]\n"
+			"casp x14, x15, x16, x17, [%[loc]]\n"
+			"stp x0, x1, [%[dst]]\n"
+			"stp x2, x3, [%[dst], #16]\n"
+			"stp x4, x5, [%[dst], #32]\n"
+			"stp x6, x7, [%[dst], #48]\n"
+			"stp x8, x9, [%[dst], #64]\n"
+			"stp x10, x11, [%[dst], #80]\n"
+			"stp x12, x13, [%[dst], #96]\n"
+			"stp x14, x15, [%[dst], #112]\n"
+			:
+			: [wdata] "r" (wdata), [dst] "r" (buf), [loc] "r" (addr)
+			: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6",
+			  "x7", "x8", "x9", "x10", "x11", "x12", "x13", "x14",
+			  "x15", "x16", "x17"
+		);
+		break;
+	case 8:
+		asm volatile(
+			".cpu  generic+lse\n"
+			"mov x16, %[wdata]\n"
+			"mov x17, %[wdata]\n"
+			"casp x0, x1, x16, x17, [%[loc]]\n"
+			"casp x2, x3, x16, x17, [%[loc]]\n"
+			"casp x4, x5, x16, x17, [%[loc]]\n"
+			"casp x6, x7, x16, x17, [%[loc]]\n"
+			"stp x0, x1, [%[dst]]\n"
+			"stp x2, x3, [%[dst], #16]\n"
+			"stp x4, x5, [%[dst], #32]\n"
+			"stp x6, x7, [%[dst], #48]\n"
+			:
+			: [wdata] "r" (wdata), [dst] "r" (buf), [loc] "r" (addr)
+			: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6",
+			  "x7", "x16", "x17"
+		);
+		break;
+	case 4:
+		asm volatile(
+			".cpu  generic+lse\n"
+			"mov x16, %[wdata]\n"
+			"mov x17, %[wdata]\n"
+			"casp x0, x1, x16, x17, [%[loc]]\n"
+			"casp x2, x3, x16, x17, [%[loc]]\n"
+			"stp x0, x1, [%[dst]]\n"
+			"stp x2, x3, [%[dst], #16]\n"
+			:
+			: [wdata] "r" (wdata), [dst] "r" (buf), [loc] "r" (addr)
+			: "memory", "x0", "x1", "x2", "x3", "x16", "x17"
+		);
+		break;
+	case 2:
+		asm volatile(
+			".cpu  generic+lse\n"
+			"mov x16, %[wdata]\n"
+			"mov x17, %[wdata]\n"
+			"casp x0, x1, x16, x17, [%[loc]]\n"
+			"stp x0, x1, [%[dst]]\n"
+			:
+			: [wdata] "r" (wdata), [dst] "r" (buf), [loc] "r" (addr)
+			: "memory", "x0", "x1", "x16", "x17"
+		);
+		break;
+	case 1:
+		buf[0] = roc_npa_aura_op_alloc(aura_handle, drop);
+		return !!buf[0];
+	}
+
+	/* Pack the pointers */
+	for (i = 0, count = 0; i < num; i++)
+		if (buf[i])
+			buf[count++] = buf[i];
+
+	return count;
+#else
+	unsigned int i, count;
+
+	for (i = 0, count = 0; i < num; i++) {
+		buf[count] = roc_npa_aura_op_alloc(aura_handle, drop);
+		if (buf[count])
+			count++;
+	}
+
+	return count;
+#endif
+}
+
+static inline unsigned int
+roc_npa_aura_op_bulk_alloc(uint64_t aura_handle, uint64_t *buf,
+			   unsigned int num, const int drop, const int partial)
+{
+	unsigned int chunk, count, num_alloc;
+
+	count = 0;
+	while (num) {
+		chunk = (num >= ROC_CN9K_NPA_BULK_ALLOC_MAX_PTRS) ?
+				      ROC_CN9K_NPA_BULK_ALLOC_MAX_PTRS :
+				      plt_align32prevpow2(num);
+
+		num_alloc =
+			roc_npa_aura_bulk_alloc(aura_handle, buf, chunk, drop);
+
+		count += num_alloc;
+		buf += num_alloc;
+		num -= num_alloc;
+
+		if (unlikely(num_alloc != chunk))
+			break;
+	}
+
+	/* If the requested number of pointers was not allocated and if partial
+	 * alloc is not desired, then free allocated pointers.
+	 */
+	if (unlikely(num != 0 && !partial)) {
+		roc_npa_aura_op_bulk_free(aura_handle, buf - count, count, 1);
+		count = 0;
+	}
+
+	return count;
+}
+
 struct roc_npa {
 	struct plt_pci_device *pci_dev;
 
Signature · 1 line
2.8.4
#236 lore raw

PATCH v5 15/52 common/cnxk: add npa performance counter support

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add APIs to read NPA performance counters.

---
 drivers/common/cnxk/roc_npa.c   | 50 +++++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npa.h   | 37 ++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map |  1 +
 3 files changed, 88 insertions(+)
drivers/common/cnxk/roc_npa.c +50 -0
index 80f5a78..f1e03b7 100644
@@ -131,6 +131,56 @@ npa_aura_pool_fini(struct mbox *mbox, uint32_t aura_id, uint64_t aura_handle)
 	return 0;
 }
 
+int
+roc_npa_pool_op_pc_reset(uint64_t aura_handle)
+{
+	struct npa_lf *lf = idev_npa_obj_get();
+	struct npa_aq_enq_req *pool_req;
+	struct npa_aq_enq_rsp *pool_rsp;
+	struct ndc_sync_op *ndc_req;
+	struct mbox_dev *mdev;
+	int rc = -ENOSPC, off;
+	struct mbox *mbox;
+
+	if (lf == NULL)
+		return NPA_ERR_PARAM;
+
+	mbox = lf->mbox;
+	mdev = &mbox->dev[0];
+	plt_npa_dbg("lf=%p aura_handle=0x%" PRIx64, lf, aura_handle);
+
+	pool_req = mbox_alloc_msg_npa_aq_enq(mbox);
+	if (pool_req == NULL)
+		return rc;
+	pool_req->aura_id = roc_npa_aura_handle_to_aura(aura_handle);
+	pool_req->ctype = NPA_AQ_CTYPE_POOL;
+	pool_req->op = NPA_AQ_INSTOP_WRITE;
+	pool_req->pool.op_pc = 0;
+	pool_req->pool_mask.op_pc = ~pool_req->pool_mask.op_pc;
+
+	rc = mbox_process(mbox);
+	if (rc < 0)
+		return rc;
+
+	off = mbox->rx_start +
+	      PLT_ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
+	pool_rsp = (struct npa_aq_enq_rsp *)((uintptr_t)mdev->mbase + off);
+
+	if (pool_rsp->hdr.rc != 0)
+		return NPA_ERR_AURA_POOL_FINI;
+
+	/* Sync NDC-NPA for LF */
+	ndc_req = mbox_alloc_msg_ndc_sync_op(mbox);
+	if (ndc_req == NULL)
+		return -ENOSPC;
+	ndc_req->npa_lf_sync = 1;
+	rc = mbox_process(mbox);
+	if (rc) {
+		plt_err("Error on NDC-NPA LF sync, rc %d", rc);
+		return NPA_ERR_AURA_POOL_FINI;
+	}
+	return 0;
+}
 static inline char *
 npa_stack_memzone_name(struct npa_lf *lf, int pool_id, char *name)
 {
drivers/common/cnxk/roc_npa.h +37 -0
index b829b23..7c6f78d 100644
@@ -146,6 +146,40 @@ roc_npa_aura_op_available(uint64_t aura_handle)
 		return reg & 0xFFFFFFFFF;
 }
 
+static inline uint64_t
+roc_npa_pool_op_performance_counter(uint64_t aura_handle, const int drop)
+{
+	union {
+		uint64_t u;
+		struct npa_aura_op_wdata_s s;
+	} op_wdata;
+	int64_t *addr;
+	uint64_t reg;
+
+	op_wdata.u = 0;
+	op_wdata.s.aura = roc_npa_aura_handle_to_aura(aura_handle);
+	if (drop)
+		op_wdata.s.drop |= BIT_ULL(63); /* DROP */
+
+	addr = (int64_t *)(roc_npa_aura_handle_to_base(aura_handle) +
+			   NPA_LF_POOL_OP_PC);
+
+	reg = roc_atomic64_add_nosync(op_wdata.u, addr);
+	/*
+	 * NPA_LF_POOL_OP_PC Read Data
+	 *
+	 * 63       49 48    48 47     0
+	 * -----------------------------
+	 * | Reserved | OP_ERR | OP_PC |
+	 * -----------------------------
+	 */
+
+	if (reg & BIT_ULL(48) /* OP_ERR */)
+		return 0;
+	else
+		return reg & 0xFFFFFFFFFFFF;
+}
+
 static inline void
 roc_npa_aura_op_bulk_free(uint64_t aura_handle, uint64_t const *buf,
 			  unsigned int num, const int fabs)
@@ -396,4 +430,7 @@ void __roc_api roc_npa_aura_op_range_set(uint64_t aura_handle,
 int __roc_api roc_npa_ctx_dump(void);
 int __roc_api roc_npa_dump(void);
 
+/* Reset operation performance counter. */
+int __roc_api roc_npa_pool_op_pc_reset(uint64_t aura_handle);
+
 #endif /* _ROC_NPA_H_ */
drivers/common/cnxk/version.map +1 -0
index 1250767..6f05448 100644
@@ -19,6 +19,7 @@ INTERNAL {
 	roc_npa_dump;
 	roc_npa_pool_create;
 	roc_npa_pool_destroy;
+	roc_npa_pool_op_pc_reset;
 	roc_npa_pool_range_update_check;
 	roc_plt_init;
 	roc_plt_init_cb_register;
Signature · 1 line
2.8.4
#237 lore raw

PATCH v5 16/52 common/cnxk: add npa batch alloc/free support

In reply to Nithin Dabilpuram

From: Ashwin Sekhar T K <[email protected]>

Add APIs to do allocations/frees in batch from
NPA pool.

---
 drivers/common/cnxk/roc_npa.h | 217 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 217 insertions(+)
drivers/common/cnxk/roc_npa.h +217 -0
index 7c6f78d..89f5c6f 100644
@@ -8,6 +8,9 @@
 #define ROC_AURA_ID_MASK       (BIT_ULL(16) - 1)
 #define ROC_AURA_OP_LIMIT_MASK (BIT_ULL(36) - 1)
 
+#define ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS 512
+#define ROC_CN10K_NPA_BATCH_FREE_MAX_PTRS  15
+
 /* 16 CASP instructions can be outstanding in CN9k, but we use only 15
  * outstanding CASPs as we run out of registers.
  */
@@ -180,6 +183,114 @@ roc_npa_pool_op_performance_counter(uint64_t aura_handle, const int drop)
 		return reg & 0xFFFFFFFFFFFF;
 }
 
+static inline int
+roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
+			       unsigned int num, const int dis_wait,
+			       const int drop)
+{
+	unsigned int i;
+	int64_t *addr;
+	uint64_t res;
+	union {
+		uint64_t u;
+		struct npa_batch_alloc_compare_s compare_s;
+	} cmp;
+
+	if (num > ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS)
+		return -1;
+
+	/* Zero first word of every cache line */
+	for (i = 0; i < num; i += (ROC_ALIGN / sizeof(uint64_t)))
+		buf[i] = 0;
+
+	addr = (int64_t *)(roc_npa_aura_handle_to_base(aura_handle) +
+			   NPA_LF_AURA_BATCH_ALLOC);
+	cmp.u = 0;
+	cmp.compare_s.aura = roc_npa_aura_handle_to_aura(aura_handle);
+	cmp.compare_s.drop = drop;
+	cmp.compare_s.stype = ALLOC_STYPE_STSTP;
+	cmp.compare_s.dis_wait = dis_wait;
+	cmp.compare_s.count = num;
+
+	res = roc_atomic64_cas(cmp.u, (uint64_t)buf, addr);
+	if (res != ALLOC_RESULT_ACCEPTED && res != ALLOC_RESULT_NOCORE)
+		return -1;
+
+	return 0;
+}
+
+static inline unsigned int
+roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num)
+{
+	unsigned int count, i;
+
+	if (num > ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS)
+		return 0;
+
+	count = 0;
+	/* Check each ROC cache line one by one */
+	for (i = 0; i < num; i += (ROC_ALIGN >> 3)) {
+		struct npa_batch_alloc_status_s *status;
+		int ccode;
+
+		status = (struct npa_batch_alloc_status_s *)&aligned_buf[i];
+
+		/* Status is updated in first 7 bits of each 128 byte cache
+		 * line. Wait until the status gets updated.
+		 */
+		do {
+			ccode = (volatile int)status->ccode;
+		} while (ccode == ALLOC_CCODE_INVAL);
+
+		count += status->count;
+	}
+
+	return count;
+}
+
+static inline unsigned int
+roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint64_t *aligned_buf,
+				 unsigned int num)
+{
+	unsigned int count, i;
+
+	if (num > ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS)
+		return 0;
+
+	count = 0;
+	/* Check each ROC cache line one by one */
+	for (i = 0; i < num; i += (ROC_ALIGN >> 3)) {
+		struct npa_batch_alloc_status_s *status;
+		int line_count, ccode;
+
+		status = (struct npa_batch_alloc_status_s *)&aligned_buf[i];
+
+		/* Status is updated in first 7 bits of each 128 byte cache
+		 * line. Wait until the status gets updated.
+		 */
+		do {
+			ccode = (volatile int)status->ccode;
+		} while (ccode == ALLOC_CCODE_INVAL);
+
+		line_count = status->count;
+
+		/* Clear the status from the cache line */
+		status->ccode = 0;
+		status->count = 0;
+
+		/* 'Compress' the allocated buffers as there can
+		 * be 'holes' at the end of the 128 byte cache
+		 * lines.
+		 */
+		memmove(&buf[count], &aligned_buf[i],
+			line_count * sizeof(uint64_t));
+
+		count += line_count;
+	}
+
+	return count;
+}
+
 static inline void
 roc_npa_aura_op_bulk_free(uint64_t aura_handle, uint64_t const *buf,
 			  unsigned int num, const int fabs)
@@ -194,6 +305,112 @@ roc_npa_aura_op_bulk_free(uint64_t aura_handle, uint64_t const *buf,
 }
 
 static inline unsigned int
+roc_npa_aura_op_batch_alloc(uint64_t aura_handle, uint64_t *buf,
+			    uint64_t *aligned_buf, unsigned int num,
+			    const int dis_wait, const int drop,
+			    const int partial)
+{
+	unsigned int count, chunk, num_alloc;
+
+	/* The buffer should be 128 byte cache line aligned */
+	if (((uint64_t)aligned_buf & (ROC_ALIGN - 1)) != 0)
+		return 0;
+
+	count = 0;
+	while (num) {
+		chunk = (num > ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS) ?
+				      ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS :
+				      num;
+
+		if (roc_npa_aura_batch_alloc_issue(aura_handle, aligned_buf,
+						   chunk, dis_wait, drop))
+			break;
+
+		num_alloc = roc_npa_aura_batch_alloc_extract(buf, aligned_buf,
+							     chunk);
+
+		count += num_alloc;
+		buf += num_alloc;
+		num -= num_alloc;
+
+		if (num_alloc != chunk)
+			break;
+	}
+
+	/* If the requested number of pointers was not allocated and if partial
+	 * alloc is not desired, then free allocated pointers.
+	 */
+	if (unlikely(num != 0 && !partial)) {
+		roc_npa_aura_op_bulk_free(aura_handle, buf - count, count, 1);
+		count = 0;
+	}
+
+	return count;
+}
+
+static inline void
+roc_npa_aura_batch_free(uint64_t aura_handle, uint64_t const *buf,
+			unsigned int num, const int fabs, uint64_t lmt_addr,
+			uint64_t lmt_id)
+{
+	uint64_t addr, tar_addr, free0;
+	volatile uint64_t *lmt_data;
+	unsigned int i;
+
+	if (num > ROC_CN10K_NPA_BATCH_FREE_MAX_PTRS)
+		return;
+
+	lmt_data = (uint64_t *)lmt_addr;
+
+	addr = roc_npa_aura_handle_to_base(aura_handle) +
+	       NPA_LF_AURA_BATCH_FREE0;
+
+	/*
+	 * NPA_LF_AURA_BATCH_FREE0
+	 *
+	 * 63   63 62  33 32       32 31  20 19    0
+	 * -----------------------------------------
+	 * | FABS | Rsvd | COUNT_EOT | Rsvd | AURA |
+	 * -----------------------------------------
+	 */
+	free0 = roc_npa_aura_handle_to_aura(aura_handle);
+	if (fabs)
+		free0 |= (0x1UL << 63);
+	if (num & 0x1)
+		free0 |= (0x1UL << 32);
+
+	/* tar_addr[4:6] is LMTST size-1 in units of 128b */
+	tar_addr = addr | ((num >> 1) << 4);
+
+	lmt_data[0] = free0;
+	for (i = 0; i < num; i++)
+		lmt_data[i + 1] = buf[i];
+
+	roc_lmt_submit_steorl(lmt_id, tar_addr);
+	plt_io_wmb();
+}
+
+static inline void
+roc_npa_aura_op_batch_free(uint64_t aura_handle, uint64_t const *buf,
+			   unsigned int num, const int fabs, uint64_t lmt_addr,
+			   uint64_t lmt_id)
+{
+	unsigned int chunk;
+
+	while (num) {
+		chunk = (num >= ROC_CN10K_NPA_BATCH_FREE_MAX_PTRS) ?
+				      ROC_CN10K_NPA_BATCH_FREE_MAX_PTRS :
+				      num;
+
+		roc_npa_aura_batch_free(aura_handle, buf, chunk, fabs, lmt_addr,
+					lmt_id);
+
+		buf += chunk;
+		num -= chunk;
+	}
+}
+
+static inline unsigned int
 roc_npa_aura_bulk_alloc(uint64_t aura_handle, uint64_t *buf, unsigned int num,
 			const int drop)
 {
Signature · 1 line
2.8.4
#238 lore raw

PATCH v5 17/52 common/cnxk: add base nix support

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add base nix support as ROC(Rest of Chip) API which will be used by generic ETHDEV PMD(net/cnxk).

This patch adds support to device init, fini, resource alloc and free API which sets up a ETHDEV PCI device of either CN9K or CN10K Marvell SoC.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_api.h      |   3 +
 drivers/common/cnxk/roc_idev.c     |  13 ++
 drivers/common/cnxk/roc_idev.h     |   2 +
 drivers/common/cnxk/roc_nix.c      | 396 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix.h      |  84 ++++++++
 drivers/common/cnxk/roc_nix_priv.h | 100 ++++++++++
 drivers/common/cnxk/roc_platform.c |   1 +
 drivers/common/cnxk/roc_platform.h |   2 +
 drivers/common/cnxk/roc_priv.h     |   3 +
 drivers/common/cnxk/roc_utils.c    |  41 ++++
 drivers/common/cnxk/version.map    |  16 ++
 12 files changed, 662 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix.c
 create mode 100644 drivers/common/cnxk/roc_nix.h
 create mode 100644 drivers/common/cnxk/roc_nix_priv.h
drivers/common/cnxk/meson.build +1 -0
index 01a8f80..1efb601 100644
@@ -15,6 +15,7 @@ sources = files('roc_dev.c',
 		'roc_irq.c',
 		'roc_mbox.c',
 		'roc_model.c',
+		'roc_nix.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
drivers/common/cnxk/roc_api.h +3 -0
index 9289c68..718916d 100644
@@ -82,6 +82,9 @@
 /* NPA */
 #include "roc_npa.h"
 
+/* NIX */
+#include "roc_nix.h"
+
 /* Utils */
 #include "roc_utils.h"
 
drivers/common/cnxk/roc_idev.c +13 -0
index bf9cce8..a92ac6a 100644
@@ -142,3 +142,16 @@ roc_idev_num_lmtlines_get(void)
 
 	return num_lmtlines;
 }
+
+struct roc_nix *
+roc_idev_npa_nix_get(void)
+{
+	struct npa_lf *npa_lf = idev_npa_obj_get();
+	struct dev *dev;
+
+	if (!npa_lf)
+		return NULL;
+
+	dev = container_of(npa_lf, struct dev, npa);
+	return dev->roc_nix;
+}
drivers/common/cnxk/roc_idev.h +2 -0
index f267865..043e8af 100644
@@ -12,4 +12,6 @@ void __roc_api roc_idev_npa_maxpools_set(uint32_t max_pools);
 uint64_t __roc_api roc_idev_lmt_base_addr_get(void);
 uint16_t __roc_api roc_idev_num_lmtlines_get(void);
 
+struct roc_nix *__roc_api roc_idev_npa_nix_get(void);
+
 #endif /* _ROC_IDEV_H_ */
drivers/common/cnxk/roc_nix.c new file +396 -0

396 lines not on this page · raw message

drivers/common/cnxk/roc_nix.h new file +84 -0

84 lines not on this page · raw message

drivers/common/cnxk/roc_nix_priv.h new file +100 -0

100 lines not on this page · raw message

drivers/common/cnxk/roc_platform.c +1 -0
index 444d223..9ac9952 100644
@@ -59,3 +59,4 @@ roc_plt_init(void)
 RTE_LOG_REGISTER(cnxk_logtype_base, pmd.cnxk.base, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_mbox, pmd.cnxk.mbox, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_npa, pmd.mempool.cnxk, NOTICE);
+RTE_LOG_REGISTER(cnxk_logtype_nix, pmd.net.cnxk, NOTICE);
drivers/common/cnxk/roc_platform.h +2 -0
index 69ec600..1d5bd56 100644
@@ -135,6 +135,7 @@
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
 extern int cnxk_logtype_npa;
+extern int cnxk_logtype_nix;
 
 #define plt_err(fmt, args...)                                                  \
 	RTE_LOG(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
@@ -153,6 +154,7 @@ extern int cnxk_logtype_npa;
 #define plt_base_dbg(fmt, ...)	plt_dbg(base, fmt, ##__VA_ARGS__)
 #define plt_mbox_dbg(fmt, ...)	plt_dbg(mbox, fmt, ##__VA_ARGS__)
 #define plt_npa_dbg(fmt, ...)	plt_dbg(npa, fmt, ##__VA_ARGS__)
+#define plt_nix_dbg(fmt, ...)	plt_dbg(nix, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)				\
drivers/common/cnxk/roc_priv.h +3 -0
index 21599dc..7371785 100644
@@ -20,4 +20,7 @@
 /* idev */
 #include "roc_idev_priv.h"
 
+/* NIX */
+#include "roc_nix_priv.h"
+
 #endif /* _ROC_PRIV_H_ */
drivers/common/cnxk/roc_utils.c +41 -0

57 lines not on this page · raw message

drivers/common/cnxk/version.map +16 -0
index 6f05448..f2eb31d 100644
@@ -3,14 +3,30 @@ INTERNAL {
 
 	cnxk_logtype_base;
 	cnxk_logtype_mbox;
+	cnxk_logtype_nix;
 	cnxk_logtype_npa;
 	roc_clk_freq_get;
 	roc_error_msg_get;
 	roc_idev_lmt_base_addr_get;
 	roc_idev_npa_maxpools_get;
 	roc_idev_npa_maxpools_set;
+	roc_idev_npa_nix_get;
 	roc_idev_num_lmtlines_get;
 	roc_model;
+	roc_nix_dev_fini;
+	roc_nix_dev_init;
+	roc_nix_get_base_chan;
+	roc_nix_get_pf;
+	roc_nix_get_pf_func;
+	roc_nix_get_vf;
+	roc_nix_get_vwqe_interval;
+	roc_nix_is_lbk;
+	roc_nix_is_pf;
+	roc_nix_is_sdp;
+	roc_nix_is_vf_or_sdp;
+	roc_nix_lf_alloc;
+	roc_nix_lf_free;
+	roc_nix_max_pkt_len;
 	roc_npa_aura_limit_modify;
 	roc_npa_aura_op_range_set;
 	roc_npa_ctx_dump;
Signature · 1 line
2.8.4
#239 lore raw

PATCH v5 18/52 common/cnxk: add nix irq support

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add support to register NIX error and completion queue IRQ's using base device class IRQ helper API's.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_nix.c      |   7 +
 drivers/common/cnxk/roc_nix.h      |  12 +
 drivers/common/cnxk/roc_nix_irq.c  | 484 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_priv.h |  18 ++
 drivers/common/cnxk/version.map    |   8 +
 6 files changed, 530 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_irq.c
drivers/common/cnxk/meson.build +1 -0
index 1efb601..19619c3 100644
@@ -16,6 +16,7 @@ sources = files('roc_dev.c',
 		'roc_mbox.c',
 		'roc_model.c',
 		'roc_nix.c',
+		'roc_nix_irq.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
drivers/common/cnxk/roc_nix.c +7 -0
index 040f78c..e64936e 100644
@@ -363,6 +363,11 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 	nix->reta_sz = reta_sz;
 	nix->mtu = ROC_NIX_DEFAULT_HW_FRS;
 
+	/* Register error and ras interrupts */
+	rc = nix_register_irqs(nix);
+	if (rc)
+		goto lf_detach;
+
 	/* Get NIX HW info */
 	roc_nix_get_hw_info(roc_nix);
 	nix->dev.drv_inited = true;
@@ -388,6 +393,8 @@ roc_nix_dev_fini(struct roc_nix *roc_nix)
 	if (!nix->dev.drv_inited)
 		goto fini;
 
+	nix_unregister_irqs(nix);
+
 	rc = nix_lf_detach(nix);
 	nix->dev.drv_inited = false;
 fini:
drivers/common/cnxk/roc_nix.h +12 -0
index fc078f8..ca96de7 100644
@@ -81,4 +81,16 @@ int __roc_api roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq,
 			       uint32_t nb_txq, uint64_t rx_cfg);
 int __roc_api roc_nix_lf_free(struct roc_nix *roc_nix);
 
+/* IRQ */
+void __roc_api roc_nix_rx_queue_intr_enable(struct roc_nix *roc_nix,
+					    uint16_t rxq_id);
+void __roc_api roc_nix_rx_queue_intr_disable(struct roc_nix *roc_nix,
+					     uint16_t rxq_id);
+void __roc_api roc_nix_err_intr_ena_dis(struct roc_nix *roc_nix, bool enb);
+void __roc_api roc_nix_ras_intr_ena_dis(struct roc_nix *roc_nix, bool enb);
+int __roc_api roc_nix_register_queue_irqs(struct roc_nix *roc_nix);
+void __roc_api roc_nix_unregister_queue_irqs(struct roc_nix *roc_nix);
+int __roc_api roc_nix_register_cq_irqs(struct roc_nix *roc_nix);
+void __roc_api roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix);
+
 #endif /* _ROC_NIX_H_ */
drivers/common/cnxk/roc_nix_irq.c new file +484 -0

484 lines not on this page · raw message

drivers/common/cnxk/roc_nix_priv.h +18 -0
index f0f4a00..c54f45a 100644
@@ -18,11 +18,25 @@
 /* Apply BP/DROP when CQ is 95% full */
 #define NIX_CQ_THRESH_LEVEL (5 * 256 / 100)
 
+/* IRQ triggered when NIX_LF_CINTX_CNT[QCOUNT] crosses this value */
+#define CQ_CQE_THRESH_DEFAULT	0x1ULL
+#define CQ_TIMER_THRESH_DEFAULT 0xAULL /* ~1usec i.e (0xA * 100nsec) */
+#define CQ_TIMER_THRESH_MAX	255
+
+struct nix_qint {
+	struct nix *nix;
+	uint8_t qintx;
+};
+
 struct nix {
 	uint16_t reta[ROC_NIX_RSS_GRPS][ROC_NIX_RSS_RETA_MAX];
 	enum roc_nix_rss_reta_sz reta_sz;
 	struct plt_pci_device *pci_dev;
 	uint16_t bpid[NIX_MAX_CHAN];
+	struct nix_qint *qints_mem;
+	struct nix_qint *cints_mem;
+	uint8_t configured_qints;
+	uint8_t configured_cints;
 	struct roc_nix_sq **sqs;
 	uint16_t vwqe_interval;
 	uint16_t tx_chan_base;
@@ -97,4 +111,8 @@ nix_priv_to_roc_nix(struct nix *nix)
 				  offsetof(struct roc_nix, reserved));
 }
 
+/* IRQ */
+int nix_register_irqs(struct nix *nix);
+void nix_unregister_irqs(struct nix *nix);
+
 #endif /* _ROC_NIX_PRIV_H_ */
drivers/common/cnxk/version.map +8 -0
index f2eb31d..b9874a1 100644
@@ -15,6 +15,7 @@ INTERNAL {
 	roc_model;
 	roc_nix_dev_fini;
 	roc_nix_dev_init;
+	roc_nix_err_intr_ena_dis;
 	roc_nix_get_base_chan;
 	roc_nix_get_pf;
 	roc_nix_get_pf_func;
@@ -27,6 +28,13 @@ INTERNAL {
 	roc_nix_lf_alloc;
 	roc_nix_lf_free;
 	roc_nix_max_pkt_len;
+	roc_nix_ras_intr_ena_dis;
+	roc_nix_register_cq_irqs;
+	roc_nix_register_queue_irqs;
+	roc_nix_rx_queue_intr_disable;
+	roc_nix_rx_queue_intr_enable;
+	roc_nix_unregister_cq_irqs;
+	roc_nix_unregister_queue_irqs;
 	roc_npa_aura_limit_modify;
 	roc_npa_aura_op_range_set;
 	roc_npa_ctx_dump;
Signature · 1 line
2.8.4
#240 lore raw

PATCH v5 19/52 common/cnxk: add nix Rx queue management API

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add nix Rx queue management API to init/modify/fini RQ context and also setup CQ(completion queue) context. Current support is both for CN9K and CN10K devices.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_nix.h       |  52 ++++
 drivers/common/cnxk/roc_nix_queue.c | 496 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map     |   6 +
 4 files changed, 555 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_queue.c
drivers/common/cnxk/meson.build +1 -0
index 19619c3..47e7c43 100644
@@ -17,6 +17,7 @@ sources = files('roc_dev.c',
 		'roc_model.c',
 		'roc_nix.c',
 		'roc_nix_irq.c',
+		'roc_nix_queue.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
drivers/common/cnxk/roc_nix.h +52 -0

62 lines not on this page · raw message

drivers/common/cnxk/roc_nix_queue.c new file +496 -0

496 lines not on this page · raw message

drivers/common/cnxk/version.map +6 -0
index b9874a1..ae51db1 100644
@@ -13,6 +13,8 @@ INTERNAL {
 	roc_idev_npa_nix_get;
 	roc_idev_num_lmtlines_get;
 	roc_model;
+	roc_nix_cq_fini;
+	roc_nix_cq_init;
 	roc_nix_dev_fini;
 	roc_nix_dev_init;
 	roc_nix_err_intr_ena_dis;
@@ -31,6 +33,10 @@ INTERNAL {
 	roc_nix_ras_intr_ena_dis;
 	roc_nix_register_cq_irqs;
 	roc_nix_register_queue_irqs;
+	roc_nix_rq_ena_dis;
+	roc_nix_rq_fini;
+	roc_nix_rq_init;
+	roc_nix_rq_modify;
 	roc_nix_rx_queue_intr_disable;
 	roc_nix_rx_queue_intr_enable;
 	roc_nix_unregister_cq_irqs;
Signature · 1 line
2.8.4
#241 lore raw

PATCH v5 20/52 common/cnxk: add nix Tx queue management API

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

This patch adds support to init/modify/fini NIX
SQ(send queue) for both CN9K and CN10K platforms.

---
 drivers/common/cnxk/roc_nix.h       |  19 ++
 drivers/common/cnxk/roc_nix_queue.c | 358 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map     |   2 +
 3 files changed, 379 insertions(+)
drivers/common/cnxk/roc_nix.h +19 -0
index 227167e..8027e6d 100644
@@ -83,6 +83,23 @@ struct roc_nix_cq {
 	uint32_t head;
 };
 
+struct roc_nix_sq {
+	/* Input parameters */
+	enum roc_nix_sq_max_sqe_sz max_sqe_sz;
+	uint32_t nb_desc;
+	uint16_t qid;
+	/* End of Input parameters */
+	uint16_t sqes_per_sqb_log2;
+	struct roc_nix *roc_nix;
+	uint64_t aura_handle;
+	int16_t nb_sqb_bufs_adj;
+	uint16_t nb_sqb_bufs;
+	plt_iova_t io_addr;
+	void *lmt_addr;
+	void *sqe_mem;
+	void *fc;
+};
+
 struct roc_nix {
 	/* Input parameters */
 	struct plt_pci_device *pci_dev;
@@ -144,5 +161,7 @@ int __roc_api roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable);
 int __roc_api roc_nix_rq_fini(struct roc_nix_rq *rq);
 int __roc_api roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq);
 int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq);
+int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq);
+int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq);
 
 #endif /* _ROC_NIX_H_ */
drivers/common/cnxk/roc_nix_queue.c +358 -0

361 lines not on this page · raw message

drivers/common/cnxk/version.map +2 -0
index ae51db1..90bbf07 100644
@@ -39,6 +39,8 @@ INTERNAL {
 	roc_nix_rq_modify;
 	roc_nix_rx_queue_intr_disable;
 	roc_nix_rx_queue_intr_enable;
+	roc_nix_sq_fini;
+	roc_nix_sq_init;
 	roc_nix_unregister_cq_irqs;
 	roc_nix_unregister_queue_irqs;
 	roc_npa_aura_limit_modify;
Signature · 1 line
2.8.4
#242 lore raw

PATCH v5 21/52 common/cnxk: add nix MAC operations support

In reply to Nithin Dabilpuram

From: Sunil Kumar Kori <[email protected]>

Add support to different MAC related operations such as MAC address set/get, link set/get, link status callback, etc.

---
 drivers/common/cnxk/meson.build   |   1 +
 drivers/common/cnxk/roc_nix.h     |  41 ++++++
 drivers/common/cnxk/roc_nix_mac.c | 298 ++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map   |  15 ++
 4 files changed, 355 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_mac.c
drivers/common/cnxk/meson.build +1 -0
index 47e7c43..b9da55b 100644
@@ -17,6 +17,7 @@ sources = files('roc_dev.c',
 		'roc_model.c',
 		'roc_nix.c',
 		'roc_nix_irq.c',
+		'roc_nix_mac.c',
 		'roc_nix_queue.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
drivers/common/cnxk/roc_nix.h +41 -0

53 lines not on this page · raw message

drivers/common/cnxk/roc_nix_mac.c new file +298 -0

298 lines not on this page · raw message

drivers/common/cnxk/version.map +15 -0
index 90bbf07..1f41a88 100644
@@ -29,6 +29,21 @@ INTERNAL {
 	roc_nix_is_vf_or_sdp;
 	roc_nix_lf_alloc;
 	roc_nix_lf_free;
+	roc_nix_mac_addr_add;
+	roc_nix_mac_addr_del;
+	roc_nix_mac_addr_set;
+	roc_nix_mac_link_cb_register;
+	roc_nix_mac_link_cb_unregister;
+	roc_nix_mac_link_event_start_stop;
+	roc_nix_mac_link_info_get;
+	roc_nix_mac_link_info_set;
+	roc_nix_mac_link_state_set;
+	roc_nix_mac_loopback_enable;
+	roc_nix_mac_max_entries_get;
+	roc_nix_mac_max_rx_len_set;
+	roc_nix_mac_mtu_set;
+	roc_nix_mac_promisc_mode_enable;
+	roc_nix_mac_rxtx_start_stop;
 	roc_nix_max_pkt_len;
 	roc_nix_ras_intr_ena_dis;
 	roc_nix_register_cq_irqs;
Signature · 1 line
2.8.4
#243 lore raw

PATCH v5 22/52 common/cnxk: add nix specific npc operations

In reply to Nithin Dabilpuram

From: Sunil Kumar Kori <[email protected]>

Add NIX specific NPC operations such as NPC mac address get/set, mcast entry add/delete, promiscuous mode enable/disable etc.

---
 drivers/common/cnxk/meson.build     |   2 +
 drivers/common/cnxk/roc_nix.h       |  25 +++++++++
 drivers/common/cnxk/roc_nix_mcast.c |  98 ++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_npc.c   | 103 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map     |   9 ++++
 5 files changed, 237 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_mcast.c
 create mode 100644 drivers/common/cnxk/roc_nix_npc.c
drivers/common/cnxk/meson.build +2 -0
index b9da55b..f216d4a 100644
@@ -18,6 +18,8 @@ sources = files('roc_dev.c',
 		'roc_nix.c',
 		'roc_nix_irq.c',
 		'roc_nix_mac.c',
+		'roc_nix_mcast.c',
+		'roc_nix_npc.c',
 		'roc_nix_queue.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
drivers/common/cnxk/roc_nix.h +25 -0
index 66e0bfa..638f827 100644
@@ -193,6 +193,18 @@ int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix,
 					   link_status_t link_update);
 void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix);
 
+/* NPC */
+int __roc_api roc_nix_npc_promisc_ena_dis(struct roc_nix *roc_nix, int enable);
+
+int __roc_api roc_nix_npc_mac_addr_set(struct roc_nix *roc_nix, uint8_t addr[]);
+
+int __roc_api roc_nix_npc_mac_addr_get(struct roc_nix *roc_nix, uint8_t *addr);
+
+int __roc_api roc_nix_npc_rx_ena_dis(struct roc_nix *roc_nix, bool enable);
+
+int __roc_api roc_nix_npc_mcast_config(struct roc_nix *roc_nix,
+				       bool mcast_enable, bool prom_enable);
+
 /* Queue */
 int __roc_api roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq,
 			      bool ena);
@@ -205,4 +217,17 @@ int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq);
 int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq);
 int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq);
 
+/* MCAST*/
+int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
+					     uint16_t nb_entries,
+					     uint8_t priority,
+					     uint16_t index[]);
+int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
+					    uint32_t index);
+int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
+					     struct mcam_entry *entry,
+					     uint32_t index, uint8_t intf,
+					     uint64_t action);
+int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix,
+					       uint32_t index, bool enable);
 #endif /* _ROC_NIX_H_ */
drivers/common/cnxk/roc_nix_mcast.c new file +98 -0

98 lines not on this page · raw message

drivers/common/cnxk/roc_nix_npc.c new file +103 -0

103 lines not on this page · raw message

drivers/common/cnxk/version.map +9 -0
index 1f41a88..bc6c988 100644
@@ -45,6 +45,15 @@ INTERNAL {
 	roc_nix_mac_promisc_mode_enable;
 	roc_nix_mac_rxtx_start_stop;
 	roc_nix_max_pkt_len;
+	roc_nix_mcast_mcam_entry_alloc;
+	roc_nix_mcast_mcam_entry_ena_dis;
+	roc_nix_mcast_mcam_entry_free;
+	roc_nix_mcast_mcam_entry_write;
+	roc_nix_npc_mac_addr_get;
+	roc_nix_npc_mac_addr_set;
+	roc_nix_npc_promisc_ena_dis;
+	roc_nix_npc_rx_ena_dis;
+	roc_nix_npc_mcast_config;
 	roc_nix_ras_intr_ena_dis;
 	roc_nix_register_cq_irqs;
 	roc_nix_register_queue_irqs;
Signature · 1 line
2.8.4
#244 lore raw

PATCH v5 23/52 common/cnxk: add nix inline IPsec config API

In reply to Nithin Dabilpuram

From: Vidya Sagar Velumuri <[email protected]>

Add API to configure NIX block for inline IPSec.

---
 drivers/common/cnxk/roc_nix.c   | 28 ++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix.h   | 10 ++++++++++
 drivers/common/cnxk/version.map |  1 +
 3 files changed, 39 insertions(+)
drivers/common/cnxk/roc_nix.c +28 -0
index e64936e..0621976 100644
@@ -81,6 +81,34 @@ roc_nix_get_pf_func(struct roc_nix *roc_nix)
 }
 
 int
+roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix, struct roc_nix_ipsec_cfg *cfg,
+			 bool enb)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_inline_ipsec_lf_cfg *lf_cfg;
+	struct mbox *mbox = (&nix->dev)->mbox;
+
+	lf_cfg = mbox_alloc_msg_nix_inline_ipsec_lf_cfg(mbox);
+	if (lf_cfg == NULL)
+		return -ENOSPC;
+
+	if (enb) {
+		lf_cfg->enable = 1;
+		lf_cfg->sa_base_addr = cfg->iova;
+		lf_cfg->ipsec_cfg1.sa_idx_w = plt_log2_u32(cfg->max_sa);
+		lf_cfg->ipsec_cfg0.lenm1_max = roc_nix_max_pkt_len(roc_nix) - 1;
+		lf_cfg->ipsec_cfg1.sa_idx_max = cfg->max_sa - 1;
+		lf_cfg->ipsec_cfg0.sa_pow2_size = plt_log2_u32(cfg->sa_size);
+		lf_cfg->ipsec_cfg0.tag_const = cfg->tag_const;
+		lf_cfg->ipsec_cfg0.tt = cfg->tt;
+	} else {
+		lf_cfg->enable = 0;
+	}
+
+	return mbox_process(mbox);
+}
+
+int
 roc_nix_max_pkt_len(struct roc_nix *roc_nix)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
drivers/common/cnxk/roc_nix.h +10 -0
index 638f827..1c097cb 100644
@@ -110,6 +110,14 @@ struct roc_nix_link_info {
 	uint64_t port : 8;
 };
 
+struct roc_nix_ipsec_cfg {
+	uint32_t sa_size;
+	uint32_t tag_const;
+	plt_iova_t iova;
+	uint16_t max_sa;
+	uint8_t tt;
+};
+
 /* Link status update callback */
 typedef void (*link_status_t)(struct roc_nix *roc_nix,
 			      struct roc_nix_link_info *link);
@@ -156,6 +164,8 @@ int __roc_api roc_nix_max_pkt_len(struct roc_nix *roc_nix);
 int __roc_api roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq,
 			       uint32_t nb_txq, uint64_t rx_cfg);
 int __roc_api roc_nix_lf_free(struct roc_nix *roc_nix);
+int __roc_api roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix,
+				       struct roc_nix_ipsec_cfg *cfg, bool enb);
 
 /* IRQ */
 void __roc_api roc_nix_rx_queue_intr_enable(struct roc_nix *roc_nix,
drivers/common/cnxk/version.map +1 -0
index bc6c988..a0df26a 100644
@@ -28,6 +28,7 @@ INTERNAL {
 	roc_nix_is_sdp;
 	roc_nix_is_vf_or_sdp;
 	roc_nix_lf_alloc;
+	roc_nix_lf_inl_ipsec_cfg;
 	roc_nix_lf_free;
 	roc_nix_mac_addr_add;
 	roc_nix_mac_addr_del;
Signature · 1 line
2.8.4
#245 lore raw

PATCH v5 24/52 common/cnxk: add nix RSS support

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add API's for default/non-default reta table setup, key set/get, and flow algo setup for CN9K and CN10K.

---
 drivers/common/cnxk/meson.build   |   1 +
 drivers/common/cnxk/roc_nix.h     |  17 +++
 drivers/common/cnxk/roc_nix_rss.c | 220 ++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map   |   7 ++
 4 files changed, 245 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_rss.c
drivers/common/cnxk/meson.build +1 -0
index f216d4a..f6a8880 100644
@@ -21,6 +21,7 @@ sources = files('roc_dev.c',
 		'roc_nix_mcast.c',
 		'roc_nix_npc.c',
 		'roc_nix_queue.c',
+		'roc_nix_rss.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
drivers/common/cnxk/roc_nix.h +17 -0
index 1c097cb..83388ce 100644
@@ -215,6 +215,23 @@ int __roc_api roc_nix_npc_rx_ena_dis(struct roc_nix *roc_nix, bool enable);
 int __roc_api roc_nix_npc_mcast_config(struct roc_nix *roc_nix,
 				       bool mcast_enable, bool prom_enable);
 
+/* RSS */
+void __roc_api roc_nix_rss_key_default_fill(struct roc_nix *roc_nix,
+					    uint8_t key[ROC_NIX_RSS_KEY_LEN]);
+void __roc_api roc_nix_rss_key_set(struct roc_nix *roc_nix,
+				   const uint8_t key[ROC_NIX_RSS_KEY_LEN]);
+void __roc_api roc_nix_rss_key_get(struct roc_nix *roc_nix,
+				   uint8_t key[ROC_NIX_RSS_KEY_LEN]);
+int __roc_api roc_nix_rss_reta_set(struct roc_nix *roc_nix, uint8_t group,
+				   uint16_t reta[ROC_NIX_RSS_RETA_MAX]);
+int __roc_api roc_nix_rss_reta_get(struct roc_nix *roc_nix, uint8_t group,
+				   uint16_t reta[ROC_NIX_RSS_RETA_MAX]);
+int __roc_api roc_nix_rss_flowkey_set(struct roc_nix *roc_nix, uint8_t *alg_idx,
+				      uint32_t flowkey, uint8_t group,
+				      int mcam_index);
+int __roc_api roc_nix_rss_default_setup(struct roc_nix *roc_nix,
+					uint32_t flowkey);
+
 /* Queue */
 int __roc_api roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq,
 			      bool ena);
drivers/common/cnxk/roc_nix_rss.c new file +220 -0

220 lines not on this page · raw message

drivers/common/cnxk/version.map +7 -0
index a0df26a..3196738 100644
@@ -62,6 +62,13 @@ INTERNAL {
 	roc_nix_rq_fini;
 	roc_nix_rq_init;
 	roc_nix_rq_modify;
+	roc_nix_rss_default_setup;
+	roc_nix_rss_flowkey_set;
+	roc_nix_rss_key_default_fill;
+	roc_nix_rss_key_get;
+	roc_nix_rss_key_set;
+	roc_nix_rss_reta_get;
+	roc_nix_rss_reta_set;
 	roc_nix_rx_queue_intr_disable;
 	roc_nix_rx_queue_intr_enable;
 	roc_nix_sq_fini;
Signature · 1 line
2.8.4
#246 lore raw

PATCH v5 25/52 common/cnxk: add nix ptp support

In reply to Nithin Dabilpuram

From: Sunil Kumar Kori <[email protected]>

Add support to enable/disable Rx and Tx PTP timestamping support. Also provide API's to register ptp info callbacks to get config change update from Kernel.

---
 drivers/common/cnxk/meson.build   |   1 +
 drivers/common/cnxk/roc_nix.h     |  16 +++++
 drivers/common/cnxk/roc_nix_ptp.c | 122 ++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map   |   6 ++
 4 files changed, 145 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_ptp.c
drivers/common/cnxk/meson.build +1 -0
index f6a8880..d01cf0b 100644
@@ -20,6 +20,7 @@ sources = files('roc_dev.c',
 		'roc_nix_mac.c',
 		'roc_nix_mcast.c',
 		'roc_nix_npc.c',
+		'roc_nix_ptp.c',
 		'roc_nix_queue.c',
 		'roc_nix_rss.c',
 		'roc_npa.c',
drivers/common/cnxk/roc_nix.h +16 -0
index 83388ce..3cc1797 100644
@@ -17,6 +17,11 @@ enum roc_nix_sq_max_sqe_sz {
 	roc_nix_maxsqesz_w8 = NIX_MAXSQESZ_W8,
 };
 
+/* Range to adjust PTP frequency. Valid range is
+ * (-ROC_NIX_PTP_FREQ_ADJUST, ROC_NIX_PTP_FREQ_ADJUST)
+ */
+#define ROC_NIX_PTP_FREQ_ADJUST (1 << 9)
+
 /* NIX LF RX offload configuration flags.
  * These are input flags to roc_nix_lf_alloc:rx_cfg
  */
@@ -244,6 +249,17 @@ int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq);
 int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq);
 int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq);
 
+/* PTP */
+int __roc_api roc_nix_ptp_rx_ena_dis(struct roc_nix *roc_nix, int enable);
+int __roc_api roc_nix_ptp_tx_ena_dis(struct roc_nix *roc_nix, int enable);
+int __roc_api roc_nix_ptp_clock_read(struct roc_nix *roc_nix, uint64_t *clock,
+				     uint64_t *tsc, uint8_t is_pmu);
+int __roc_api roc_nix_ptp_sync_time_adjust(struct roc_nix *roc_nix,
+					   int64_t delta);
+int __roc_api roc_nix_ptp_info_cb_register(struct roc_nix *roc_nix,
+					   ptp_info_update_t ptp_update);
+void __roc_api roc_nix_ptp_info_cb_unregister(struct roc_nix *roc_nix);
+
 /* MCAST*/
 int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
 					     uint16_t nb_entries,
drivers/common/cnxk/roc_nix_ptp.c new file +122 -0

122 lines not on this page · raw message

drivers/common/cnxk/version.map +6 -0
index 3196738..2267cf7 100644
@@ -55,6 +55,12 @@ INTERNAL {
 	roc_nix_npc_promisc_ena_dis;
 	roc_nix_npc_rx_ena_dis;
 	roc_nix_npc_mcast_config;
+	roc_nix_ptp_clock_read;
+	roc_nix_ptp_info_cb_register;
+	roc_nix_ptp_info_cb_unregister;
+	roc_nix_ptp_rx_ena_dis;
+	roc_nix_ptp_sync_time_adjust;
+	roc_nix_ptp_tx_ena_dis;
 	roc_nix_ras_intr_ena_dis;
 	roc_nix_register_cq_irqs;
 	roc_nix_register_queue_irqs;
Signature · 1 line
2.8.4
#247 lore raw

PATCH v5 26/52 common/cnxk: add nix stats support

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add API to provide Rx and Tx stats for a given NIX.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_nix.h       |  53 ++++++++
 drivers/common/cnxk/roc_nix_stats.c | 239 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map     |   4 +
 4 files changed, 297 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_stats.c
drivers/common/cnxk/meson.build +1 -0
index d01cf0b..4c48f55 100644
@@ -23,6 +23,7 @@ sources = files('roc_dev.c',
 		'roc_nix_ptp.c',
 		'roc_nix_queue.c',
 		'roc_nix_rss.c',
+		'roc_nix_stats.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
drivers/common/cnxk/roc_nix.h +53 -0

65 lines not on this page · raw message

drivers/common/cnxk/roc_nix_stats.c new file +239 -0

239 lines not on this page · raw message

drivers/common/cnxk/version.map +4 -0
index 2267cf7..2ff3065 100644
@@ -79,6 +79,10 @@ INTERNAL {
 	roc_nix_rx_queue_intr_enable;
 	roc_nix_sq_fini;
 	roc_nix_sq_init;
+	roc_nix_stats_get;
+	roc_nix_stats_queue_get;
+	roc_nix_stats_queue_reset;
+	roc_nix_stats_reset;
 	roc_nix_unregister_cq_irqs;
 	roc_nix_unregister_queue_irqs;
 	roc_npa_aura_limit_modify;
Signature · 1 line
2.8.4
#248 lore raw

PATCH v5 27/52 common/cnxk: add support for nix extended stats

In reply to Nithin Dabilpuram

From: Satha Rao <[email protected]>

Add support for retrieving NIX extended stats that are per NIX LF and per LMAC.

---
 drivers/common/cnxk/roc_nix.h        |  18 ++++
 drivers/common/cnxk/roc_nix_stats.c  | 172 +++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_xstats.h | 204 +++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map      |   3 +
 4 files changed, 397 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_xstats.h
drivers/common/cnxk/roc_nix.h +18 -0
index 45aca83..137889a 100644
@@ -158,6 +158,18 @@ struct roc_nix_link_info {
 	uint64_t port : 8;
 };
 
+/** Maximum name length for extended statistics counters */
+#define ROC_NIX_XSTATS_NAME_SIZE 64
+
+struct roc_nix_xstat {
+	uint64_t id;	/**< The index in xstats name array. */
+	uint64_t value; /**< The statistic counter value. */
+};
+
+struct roc_nix_xstat_name {
+	char name[ROC_NIX_XSTATS_NAME_SIZE];
+};
+
 struct roc_nix_ipsec_cfg {
 	uint32_t sa_size;
 	uint32_t tag_const;
@@ -289,6 +301,12 @@ int __roc_api roc_nix_stats_queue_get(struct roc_nix *roc_nix, uint16_t qid,
 				      struct roc_nix_stats_queue *qstats);
 int __roc_api roc_nix_stats_queue_reset(struct roc_nix *roc_nix, uint16_t qid,
 					bool is_rx);
+int __roc_api roc_nix_num_xstats_get(struct roc_nix *roc_nix);
+int __roc_api roc_nix_xstats_get(struct roc_nix *roc_nix,
+				 struct roc_nix_xstat *xstats, unsigned int n);
+int __roc_api roc_nix_xstats_names_get(struct roc_nix *roc_nix,
+				       struct roc_nix_xstat_name *xstats_names,
+				       unsigned int limit);
 
 /* Queue */
 int __roc_api roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq,
drivers/common/cnxk/roc_nix_stats.c +172 -0

187 lines not on this page · raw message

drivers/common/cnxk/roc_nix_xstats.h new file +204 -0

204 lines not on this page · raw message

drivers/common/cnxk/version.map +3 -0
index 2ff3065..7267257 100644
@@ -83,6 +83,9 @@ INTERNAL {
 	roc_nix_stats_queue_get;
 	roc_nix_stats_queue_reset;
 	roc_nix_stats_reset;
+	roc_nix_num_xstats_get;
+	roc_nix_xstats_get;
+	roc_nix_xstats_names_get;
 	roc_nix_unregister_cq_irqs;
 	roc_nix_unregister_queue_irqs;
 	roc_npa_aura_limit_modify;
Signature · 1 line
2.8.4
#249 lore raw

PATCH v5 28/52 common/cnxk: add nix debug dump support

In reply to Nithin Dabilpuram

From: Jerin Jacob <[email protected]>

Add support to dump NIX RQ, SQ and CQ contexts apart from NIX LF registers.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_nix.h       |  10 +
 drivers/common/cnxk/roc_nix_debug.c | 805 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_irq.c   |  11 +
 drivers/common/cnxk/version.map     |   8 +
 5 files changed, 835 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_debug.c
drivers/common/cnxk/meson.build +1 -0
index 4c48f55..57253e4 100644
@@ -16,6 +16,7 @@ sources = files('roc_dev.c',
 		'roc_mbox.c',
 		'roc_model.c',
 		'roc_nix.c',
+		'roc_nix_debug.c',
 		'roc_nix_irq.c',
 		'roc_nix_mac.c',
 		'roc_nix_mcast.c',
drivers/common/cnxk/roc_nix.h +10 -0
index 137889a..048a536 100644
@@ -227,6 +227,16 @@ int __roc_api roc_nix_lf_free(struct roc_nix *roc_nix);
 int __roc_api roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix,
 				       struct roc_nix_ipsec_cfg *cfg, bool enb);
 
+/* Debug */
+int __roc_api roc_nix_lf_get_reg_count(struct roc_nix *roc_nix);
+int __roc_api roc_nix_lf_reg_dump(struct roc_nix *roc_nix, uint64_t *data);
+int __roc_api roc_nix_queues_ctx_dump(struct roc_nix *roc_nix);
+void __roc_api roc_nix_cqe_dump(const struct nix_cqe_hdr_s *cq);
+void __roc_api roc_nix_rq_dump(struct roc_nix_rq *rq);
+void __roc_api roc_nix_cq_dump(struct roc_nix_cq *cq);
+void __roc_api roc_nix_sq_dump(struct roc_nix_sq *sq);
+void __roc_api roc_nix_dump(struct roc_nix *roc_nix);
+
 /* IRQ */
 void __roc_api roc_nix_rx_queue_intr_enable(struct roc_nix *roc_nix,
 					    uint16_t rxq_id);
drivers/common/cnxk/roc_nix_debug.c new file +805 -0

805 lines not on this page · raw message

drivers/common/cnxk/roc_nix_irq.c +11 -0
index 79f25b0..32be64a 100644
@@ -74,6 +74,9 @@ nix_lf_err_irq(void *param)
 
 	/* Clear interrupt */
 	plt_write64(intr, nix->base + NIX_LF_ERR_INT);
+	/* Dump registers to std out */
+	roc_nix_lf_reg_dump(nix_priv_to_roc_nix(nix), NULL);
+	roc_nix_queues_ctx_dump(nix_priv_to_roc_nix(nix));
 }
 
 static int
@@ -119,6 +122,10 @@ nix_lf_ras_irq(void *param)
 	plt_err("Ras_intr=0x%" PRIx64 " pf=%d, vf=%d", intr, dev->pf, dev->vf);
 	/* Clear interrupt */
 	plt_write64(intr, nix->base + NIX_LF_RAS);
+
+	/* Dump registers to std out */
+	roc_nix_lf_reg_dump(nix_priv_to_roc_nix(nix), NULL);
+	roc_nix_queues_ctx_dump(nix_priv_to_roc_nix(nix));
 }
 
 static int
@@ -279,6 +286,10 @@ nix_lf_q_irq(void *param)
 
 	/* Clear interrupt */
 	plt_write64(intr, nix->base + NIX_LF_QINTX_INT(qintx));
+
+	/* Dump registers to std out */
+	roc_nix_lf_reg_dump(nix_priv_to_roc_nix(nix), NULL);
+	roc_nix_queues_ctx_dump(nix_priv_to_roc_nix(nix));
 }
 
 int
drivers/common/cnxk/version.map +8 -0
index 7267257..4dbfa00 100644
@@ -13,10 +13,13 @@ INTERNAL {
 	roc_idev_npa_nix_get;
 	roc_idev_num_lmtlines_get;
 	roc_model;
+	roc_nix_cq_dump;
 	roc_nix_cq_fini;
 	roc_nix_cq_init;
+	roc_nix_cqe_dump;
 	roc_nix_dev_fini;
 	roc_nix_dev_init;
+	roc_nix_dump;
 	roc_nix_err_intr_ena_dis;
 	roc_nix_get_base_chan;
 	roc_nix_get_pf;
@@ -30,6 +33,8 @@ INTERNAL {
 	roc_nix_lf_alloc;
 	roc_nix_lf_inl_ipsec_cfg;
 	roc_nix_lf_free;
+	roc_nix_lf_get_reg_count;
+	roc_nix_lf_reg_dump;
 	roc_nix_mac_addr_add;
 	roc_nix_mac_addr_del;
 	roc_nix_mac_addr_set;
@@ -61,9 +66,11 @@ INTERNAL {
 	roc_nix_ptp_rx_ena_dis;
 	roc_nix_ptp_sync_time_adjust;
 	roc_nix_ptp_tx_ena_dis;
+	roc_nix_queues_ctx_dump;
 	roc_nix_ras_intr_ena_dis;
 	roc_nix_register_cq_irqs;
 	roc_nix_register_queue_irqs;
+	roc_nix_rq_dump;
 	roc_nix_rq_ena_dis;
 	roc_nix_rq_fini;
 	roc_nix_rq_init;
@@ -77,6 +84,7 @@ INTERNAL {
 	roc_nix_rss_reta_set;
 	roc_nix_rx_queue_intr_disable;
 	roc_nix_rx_queue_intr_enable;
+	roc_nix_sq_dump;
 	roc_nix_sq_fini;
 	roc_nix_sq_init;
 	roc_nix_stats_get;
Signature · 1 line
2.8.4
#250 lore raw

PATCH v5 29/52 common/cnxk: add VLAN filter support

In reply to Nithin Dabilpuram

From: Sunil Kumar Kori <[email protected]>

Add helper API to support VLAN filtering and stripping on Rx and VLAN insertion on Tx.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_nix.h      |  45 ++++++++
 drivers/common/cnxk/roc_nix_vlan.c | 205 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map    |   8 ++
 4 files changed, 259 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_vlan.c
drivers/common/cnxk/meson.build +1 -0
index 57253e4..f975681 100644
@@ -25,6 +25,7 @@ sources = files('roc_dev.c',
 		'roc_nix_queue.c',
 		'roc_nix_rss.c',
 		'roc_nix_stats.c',
+		'roc_nix_vlan.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
drivers/common/cnxk/roc_nix.h +45 -0

57 lines not on this page · raw message

drivers/common/cnxk/roc_nix_vlan.c new file +205 -0

205 lines not on this page · raw message

drivers/common/cnxk/version.map +8 -0
index 4dbfa00..5e90129 100644
@@ -96,6 +96,14 @@ INTERNAL {
 	roc_nix_xstats_names_get;
 	roc_nix_unregister_cq_irqs;
 	roc_nix_unregister_queue_irqs;
+	roc_nix_vlan_insert_ena_dis;
+	roc_nix_vlan_mcam_entry_alloc_and_write;
+	roc_nix_vlan_mcam_entry_ena_dis;
+	roc_nix_vlan_mcam_entry_free;
+	roc_nix_vlan_mcam_entry_read;
+	roc_nix_vlan_mcam_entry_write;
+	roc_nix_vlan_strip_vtag_ena_dis;
+	roc_nix_vlan_tpid_set;
 	roc_npa_aura_limit_modify;
 	roc_npa_aura_op_range_set;
 	roc_npa_ctx_dump;
Signature · 1 line
2.8.4
#251 lore raw

PATCH v5 30/52 common/cnxk: add nix flow control support

In reply to Nithin Dabilpuram

From: Sunil Kumar Kori <[email protected]>

Add support to enable/disable Rx/Tx flow control and pause frame configuration on NIX.

---
 drivers/common/cnxk/meson.build  |   1 +
 drivers/common/cnxk/roc_nix.h    |  34 ++++++
 drivers/common/cnxk/roc_nix_fc.c | 251 +++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map  |   4 +
 4 files changed, 290 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_fc.c
drivers/common/cnxk/meson.build +1 -0
index f975681..33eeb8c 100644
@@ -17,6 +17,7 @@ sources = files('roc_dev.c',
 		'roc_model.c',
 		'roc_nix.c',
 		'roc_nix_debug.c',
+		'roc_nix_fc.c',
 		'roc_nix_irq.c',
 		'roc_nix_mac.c',
 		'roc_nix_mcast.c',
drivers/common/cnxk/roc_nix.h +34 -0
index ba3575b..2158f8c 100644
@@ -17,6 +17,13 @@ enum roc_nix_sq_max_sqe_sz {
 	roc_nix_maxsqesz_w8 = NIX_MAXSQESZ_W8,
 };
 
+enum roc_nix_fc_mode {
+	ROC_NIX_FC_NONE = 0,
+	ROC_NIX_FC_RX,
+	ROC_NIX_FC_TX,
+	ROC_NIX_FC_FULL
+};
+
 enum roc_nix_vlan_type {
 	ROC_NIX_VLAN_TYPE_INNER = 0x01,
 	ROC_NIX_VLAN_TYPE_OUTER = 0x02,
@@ -37,6 +44,21 @@ struct roc_nix_vlan_config {
 	};
 };
 
+struct roc_nix_fc_cfg {
+	bool cq_cfg_valid;
+	union {
+		struct {
+			bool enable;
+		} rxchan_cfg;
+
+		struct {
+			uint32_t rq;
+			uint16_t cq_drop;
+			bool enable;
+		} cq_cfg;
+	};
+};
+
 /* Range to adjust PTP frequency. Valid range is
  * (-ROC_NIX_PTP_FREQ_ADJUST, ROC_NIX_PTP_FREQ_ADJUST)
  */
@@ -293,6 +315,18 @@ int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix,
 					   link_status_t link_update);
 void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix);
 
+/* Flow control */
+int __roc_api roc_nix_fc_config_set(struct roc_nix *roc_nix,
+				    struct roc_nix_fc_cfg *fc_cfg);
+
+int __roc_api roc_nix_fc_config_get(struct roc_nix *roc_nix,
+				    struct roc_nix_fc_cfg *fc_cfg);
+
+int __roc_api roc_nix_fc_mode_set(struct roc_nix *roc_nix,
+				  enum roc_nix_fc_mode mode);
+
+enum roc_nix_fc_mode __roc_api roc_nix_fc_mode_get(struct roc_nix *roc_nix);
+
 /* NPC */
 int __roc_api roc_nix_npc_promisc_ena_dis(struct roc_nix *roc_nix, int enable);
 
drivers/common/cnxk/roc_nix_fc.c new file +251 -0

251 lines not on this page · raw message

drivers/common/cnxk/version.map +4 -0
index 5e90129..48182a0 100644
@@ -21,6 +21,10 @@ INTERNAL {
 	roc_nix_dev_init;
 	roc_nix_dump;
 	roc_nix_err_intr_ena_dis;
+	roc_nix_fc_config_get;
+	roc_nix_fc_config_set;
+	roc_nix_fc_mode_set;
+	roc_nix_fc_mode_get;
 	roc_nix_get_base_chan;
 	roc_nix_get_pf;
 	roc_nix_get_pf_func;
Signature · 1 line
2.8.4
#252 lore raw

PATCH v5 31/52 common/cnxk: add nix LSO support and misc utils

In reply to Nithin Dabilpuram

From: Sunil Kumar Kori <[email protected]>

Add support to create LSO formats for TCP segmentation offload for IPv4/IPv6, tunnel and non-tunnel protocols. Tunnel protocol support is for GRE and UDP based tunnel protocols.

This patch also adds other helper API to retrieve eeprom info and configure Rx for different switch headers.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_nix.h       |  28 +++
 drivers/common/cnxk/roc_nix_debug.c |  16 ++
 drivers/common/cnxk/roc_nix_ops.c   | 438 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_priv.h  |   2 +
 drivers/common/cnxk/version.map     |   5 +
 6 files changed, 490 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_ops.c
drivers/common/cnxk/meson.build +1 -0
index 33eeb8c..d8514b3 100644
@@ -22,6 +22,7 @@ sources = files('roc_dev.c',
 		'roc_nix_mac.c',
 		'roc_nix_mcast.c',
 		'roc_nix_npc.c',
+		'roc_nix_ops.c',
 		'roc_nix_ptp.c',
 		'roc_nix_queue.c',
 		'roc_nix_rss.c',
drivers/common/cnxk/roc_nix.h +28 -0
index 2158f8c..ce8c252 100644
@@ -59,6 +59,12 @@ struct roc_nix_fc_cfg {
 	};
 };
 
+struct roc_nix_eeprom_info {
+#define ROC_NIX_EEPROM_SIZE 256
+	uint16_t sff_id;
+	uint8_t buf[ROC_NIX_EEPROM_SIZE];
+};
+
 /* Range to adjust PTP frequency. Valid range is
  * (-ROC_NIX_PTP_FREQ_ADJUST, ROC_NIX_PTP_FREQ_ADJUST)
  */
@@ -246,6 +252,14 @@ struct roc_nix {
 	uint8_t reserved[ROC_NIX_MEM_SZ] __plt_cache_aligned;
 } __plt_cache_aligned;
 
+enum roc_nix_lso_tun_type {
+	ROC_NIX_LSO_TUN_V4V4,
+	ROC_NIX_LSO_TUN_V4V6,
+	ROC_NIX_LSO_TUN_V6V4,
+	ROC_NIX_LSO_TUN_V6V6,
+	ROC_NIX_LSO_TUN_MAX,
+};
+
 /* Dev */
 int __roc_api roc_nix_dev_init(struct roc_nix *roc_nix);
 int __roc_api roc_nix_dev_fini(struct roc_nix *roc_nix);
@@ -315,6 +329,20 @@ int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix,
 					   link_status_t link_update);
 void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix);
 
+/* Ops */
+int __roc_api roc_nix_switch_hdr_set(struct roc_nix *roc_nix,
+				     uint64_t switch_header_type);
+int __roc_api roc_nix_lso_fmt_setup(struct roc_nix *roc_nix);
+int __roc_api roc_nix_lso_fmt_get(struct roc_nix *roc_nix,
+				  uint8_t udp_tun[ROC_NIX_LSO_TUN_MAX],
+				  uint8_t tun[ROC_NIX_LSO_TUN_MAX]);
+int __roc_api roc_nix_lso_custom_fmt_setup(struct roc_nix *roc_nix,
+					   struct nix_lso_format *fields,
+					   uint16_t nb_fields);
+
+int __roc_api roc_nix_eeprom_info_get(struct roc_nix *roc_nix,
+				      struct roc_nix_eeprom_info *info);
+
 /* Flow control */
 int __roc_api roc_nix_fc_config_set(struct roc_nix *roc_nix,
 				    struct roc_nix_fc_cfg *fc_cfg);
drivers/common/cnxk/roc_nix_debug.c +16 -0
index 00712d5..a0cf98e 100644
@@ -786,6 +786,22 @@ roc_nix_dump(struct roc_nix *roc_nix)
 	nix_dump("  \tnb_tx_queues = %d", nix->nb_tx_queues);
 	nix_dump("  \tlso_tsov6_idx = %d", nix->lso_tsov6_idx);
 	nix_dump("  \tlso_tsov4_idx = %d", nix->lso_tsov4_idx);
+	nix_dump("  \tlso_udp_tun_v4v4 = %d",
+		 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	nix_dump("  \tlso_udp_tun_v4v6 = %d",
+		 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	nix_dump("  \tlso_udp_tun_v6v4 = %d",
+		 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	nix_dump("  \tlso_udp_tun_v6v6 = %d",
+		 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+	nix_dump("  \tlso_tun_v4v4 = %d",
+		 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	nix_dump("  \tlso_tun_v4v6 = %d",
+		 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	nix_dump("  \tlso_tun_v6v4 = %d",
+		 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	nix_dump("  \tlso_tun_v6v6 = %d",
+		 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
 	nix_dump("  \tlf_rx_stats = %d", nix->lf_rx_stats);
 	nix_dump("  \tlf_tx_stats = %d", nix->lf_tx_stats);
 	nix_dump("  \trx_chan_cnt = %d", nix->rx_chan_cnt);
drivers/common/cnxk/roc_nix_ops.c new file +438 -0

438 lines not on this page · raw message

drivers/common/cnxk/roc_nix_priv.h +2 -0
index c54f45a..115ee34 100644
@@ -45,6 +45,8 @@ struct nix {
 	uint16_t nb_tx_queues;
 	uint8_t lso_tsov6_idx;
 	uint8_t lso_tsov4_idx;
+	uint8_t lso_udp_tun_idx[ROC_NIX_LSO_TUN_MAX];
+	uint8_t lso_tun_idx[ROC_NIX_LSO_TUN_MAX];
 	uint8_t lf_rx_stats;
 	uint8_t lf_tx_stats;
 	uint8_t rx_chan_cnt;
drivers/common/cnxk/version.map +5 -0
index 48182a0..299fd90 100644
@@ -39,6 +39,9 @@ INTERNAL {
 	roc_nix_lf_free;
 	roc_nix_lf_get_reg_count;
 	roc_nix_lf_reg_dump;
+	roc_nix_lso_custom_fmt_setup;
+	roc_nix_lso_fmt_get;
+	roc_nix_lso_fmt_setup;
 	roc_nix_mac_addr_add;
 	roc_nix_mac_addr_del;
 	roc_nix_mac_addr_set;
@@ -98,6 +101,8 @@ INTERNAL {
 	roc_nix_num_xstats_get;
 	roc_nix_xstats_get;
 	roc_nix_xstats_names_get;
+	roc_nix_switch_hdr_set;
+	roc_nix_eeprom_info_get;
 	roc_nix_unregister_cq_irqs;
 	roc_nix_unregister_queue_irqs;
 	roc_nix_vlan_insert_ena_dis;
Signature · 1 line
2.8.4
#253 lore raw

PATCH v5 32/52 common/cnxk: add nix traffic management base support

In reply to Nithin Dabilpuram

Add nix traffic management base support to init/fini node, shaper profile and topology, setup SQ for a given user hierarchy or default internal hierarchy.

---
 drivers/common/cnxk/meson.build        |   3 +
 drivers/common/cnxk/roc_nix.c          |   7 +
 drivers/common/cnxk/roc_nix.h          |  26 +++
 drivers/common/cnxk/roc_nix_priv.h     | 219 ++++++++++++++++++
 drivers/common/cnxk/roc_nix_queue.c    |   9 +
 drivers/common/cnxk/roc_nix_tm.c       | 397 +++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm_ops.c   |  67 ++++++
 drivers/common/cnxk/roc_nix_tm_utils.c |  62 +++++
 drivers/common/cnxk/roc_platform.c     |   1 +
 drivers/common/cnxk/roc_platform.h     |   2 +
 drivers/common/cnxk/version.map        |   3 +
 11 files changed, 796 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_nix_tm.c
 create mode 100644 drivers/common/cnxk/roc_nix_tm_ops.c
 create mode 100644 drivers/common/cnxk/roc_nix_tm_utils.c
drivers/common/cnxk/meson.build +3 -0
index d8514b3..b453364 100644
@@ -27,6 +27,9 @@ sources = files('roc_dev.c',
 		'roc_nix_queue.c',
 		'roc_nix_rss.c',
 		'roc_nix_stats.c',
+		'roc_nix_tm.c',
+		'roc_nix_tm_ops.c',
+		'roc_nix_tm_utils.c',
 		'roc_nix_vlan.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
drivers/common/cnxk/roc_nix.c +7 -0
index 0621976..d6b288f 100644
@@ -396,11 +396,17 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 	if (rc)
 		goto lf_detach;
 
+	rc = nix_tm_conf_init(roc_nix);
+	if (rc)
+		goto unregister_irqs;
+
 	/* Get NIX HW info */
 	roc_nix_get_hw_info(roc_nix);
 	nix->dev.drv_inited = true;
 
 	return 0;
+unregister_irqs:
+	nix_unregister_irqs(nix);
 lf_detach:
 	nix_lf_detach(nix);
 dev_fini:
@@ -421,6 +427,7 @@ roc_nix_dev_fini(struct roc_nix *roc_nix)
 	if (!nix->dev.drv_inited)
 		goto fini;
 
+	nix_tm_conf_fini(roc_nix);
 	nix_unregister_irqs(nix);
 
 	rc = nix_lf_detach(nix);
drivers/common/cnxk/roc_nix.h +26 -0
index ce8c252..1ad0e72 100644
@@ -305,6 +305,32 @@ void __roc_api roc_nix_unregister_queue_irqs(struct roc_nix *roc_nix);
 int __roc_api roc_nix_register_cq_irqs(struct roc_nix *roc_nix);
 void __roc_api roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix);
 
+/* Traffic Management */
+#define ROC_NIX_TM_MAX_SCHED_WT	       ((uint8_t)~0)
+
+enum roc_nix_tm_tree {
+	ROC_NIX_TM_DEFAULT = 0,
+	ROC_NIX_TM_RLIMIT,
+	ROC_NIX_TM_USER,
+	ROC_NIX_TM_TREE_MAX,
+};
+
+enum roc_tm_node_level {
+	ROC_TM_LVL_ROOT = 0,
+	ROC_TM_LVL_SCH1,
+	ROC_TM_LVL_SCH2,
+	ROC_TM_LVL_SCH3,
+	ROC_TM_LVL_SCH4,
+	ROC_TM_LVL_QUEUE,
+	ROC_TM_LVL_MAX,
+};
+
+/*
+ * TM runtime hierarchy init API.
+ */
+int __roc_api roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable);
+int __roc_api roc_nix_tm_sq_flush_spin(struct roc_nix_sq *sq);
+
 /* MAC */
 int __roc_api roc_nix_mac_rxtx_start_stop(struct roc_nix *roc_nix, bool start);
 int __roc_api roc_nix_mac_link_event_start_stop(struct roc_nix *roc_nix,
drivers/common/cnxk/roc_nix_priv.h +219 -0

241 lines not on this page · raw message

drivers/common/cnxk/roc_nix_queue.c +9 -0
index c5287a9..fbf7efa 100644
@@ -788,6 +788,12 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq)
 	if (rc)
 		goto nomem;
 
+	rc = nix_tm_leaf_data_get(nix, sq->qid, &rr_quantum, &smq);
+	if (rc) {
+		rc = NIX_ERR_TM_LEAF_NODE_GET;
+		goto nomem;
+	}
+
 	/* Init SQ context */
 	if (roc_model_is_cn9k())
 		sq_cn9k_init(nix, sq, rr_quantum, smq);
@@ -831,6 +837,8 @@ roc_nix_sq_fini(struct roc_nix_sq *sq)
 
 	qid = sq->qid;
 
+	rc = nix_tm_sq_flush_pre(sq);
+
 	/* Release SQ context */
 	if (roc_model_is_cn9k())
 		rc |= sq_cn9k_fini(roc_nix_to_nix_priv(sq->roc_nix), sq);
@@ -845,6 +853,7 @@ roc_nix_sq_fini(struct roc_nix_sq *sq)
 	if (mbox_process(mbox))
 		rc |= NIX_ERR_NDC_SYNC;
 
+	rc |= nix_tm_sq_flush_post(sq);
 	rc |= roc_npa_pool_destroy(sq->aura_handle);
 	plt_free(sq->fc);
 	plt_free(sq->sqe_mem);
drivers/common/cnxk/roc_nix_tm.c new file +397 -0

397 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_ops.c new file +67 -0

67 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_utils.c new file +62 -0

62 lines not on this page · raw message

drivers/common/cnxk/roc_platform.c +1 -0
index 9ac9952..2380540 100644
@@ -60,3 +60,4 @@ RTE_LOG_REGISTER(cnxk_logtype_base, pmd.cnxk.base, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_mbox, pmd.cnxk.mbox, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_npa, pmd.mempool.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_nix, pmd.net.cnxk, NOTICE);
+RTE_LOG_REGISTER(cnxk_logtype_tm, pmd.net.cnxk.tm, NOTICE);
drivers/common/cnxk/roc_platform.h +2 -0
index 1d5bd56..da9c30b 100644
@@ -136,6 +136,7 @@ extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
 extern int cnxk_logtype_npa;
 extern int cnxk_logtype_nix;
+extern int cnxk_logtype_tm;
 
 #define plt_err(fmt, args...)                                                  \
 	RTE_LOG(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
@@ -155,6 +156,7 @@ extern int cnxk_logtype_nix;
 #define plt_mbox_dbg(fmt, ...)	plt_dbg(mbox, fmt, ##__VA_ARGS__)
 #define plt_npa_dbg(fmt, ...)	plt_dbg(npa, fmt, ##__VA_ARGS__)
 #define plt_nix_dbg(fmt, ...)	plt_dbg(nix, fmt, ##__VA_ARGS__)
+#define plt_tm_dbg(fmt, ...)	plt_dbg(tm, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)				\
drivers/common/cnxk/version.map +3 -0
index 299fd90..5e035d1 100644
@@ -5,6 +5,7 @@ INTERNAL {
 	cnxk_logtype_mbox;
 	cnxk_logtype_nix;
 	cnxk_logtype_npa;
+	cnxk_logtype_tm;
 	roc_clk_freq_get;
 	roc_error_msg_get;
 	roc_idev_lmt_base_addr_get;
@@ -103,6 +104,8 @@ INTERNAL {
 	roc_nix_xstats_names_get;
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
+	roc_nix_tm_sq_aura_fc;
+	roc_nix_tm_sq_flush_spin;
 	roc_nix_unregister_cq_irqs;
 	roc_nix_unregister_queue_irqs;
 	roc_nix_vlan_insert_ena_dis;
Signature · 1 line
2.8.4
#254 lore raw

PATCH v5 33/52 common/cnxk: add nix tm support to add/delete node

In reply to Nithin Dabilpuram

Add support to add/delete nodes in a hierarchy. This patch also adds misc utils to get node name, walk through nodes etc.

---
 drivers/common/cnxk/roc_nix.h          |  42 +++++++
 drivers/common/cnxk/roc_nix_priv.h     |  14 +++
 drivers/common/cnxk/roc_nix_tm.c       | 205 +++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm_ops.c   |  88 ++++++++++++++
 drivers/common/cnxk/roc_nix_tm_utils.c | 212 +++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map        |   7 ++
 6 files changed, 568 insertions(+)
drivers/common/cnxk/roc_nix.h +42 -0
index 1ad0e72..d656909 100644
@@ -307,6 +307,8 @@ void __roc_api roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix);
 
 /* Traffic Management */
 #define ROC_NIX_TM_MAX_SCHED_WT	       ((uint8_t)~0)
+#define ROC_NIX_TM_SHAPER_PROFILE_NONE UINT32_MAX
+#define ROC_NIX_TM_NODE_ID_INVALID     UINT32_MAX
 
 enum roc_nix_tm_tree {
 	ROC_NIX_TM_DEFAULT = 0,
@@ -331,6 +333,46 @@ enum roc_tm_node_level {
 int __roc_api roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable);
 int __roc_api roc_nix_tm_sq_flush_spin(struct roc_nix_sq *sq);
 
+/*
+ * TM User hierarchy API.
+ */
+
+struct roc_nix_tm_node {
+#define ROC_NIX_TM_NODE_SZ (128)
+	uint8_t reserved[ROC_NIX_TM_NODE_SZ];
+
+	uint32_t id;
+	uint32_t parent_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t shaper_profile_id;
+	uint16_t lvl;
+	bool pkt_mode;
+	bool pkt_mode_set;
+	/* Function to free this memory */
+	void (*free_fn)(void *node);
+};
+
+int __roc_api roc_nix_tm_node_add(struct roc_nix *roc_nix,
+				  struct roc_nix_tm_node *roc_node);
+int __roc_api roc_nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
+				     bool free);
+int __roc_api roc_nix_tm_node_pkt_mode_update(struct roc_nix *roc_nix,
+					      uint32_t node_id, bool pkt_mode);
+
+struct roc_nix_tm_node *__roc_api roc_nix_tm_node_get(struct roc_nix *roc_nix,
+						      uint32_t node_id);
+struct roc_nix_tm_node *__roc_api
+roc_nix_tm_node_next(struct roc_nix *roc_nix, struct roc_nix_tm_node *__prev);
+
+/*
+ * TM utilities API.
+ */
+int __roc_api roc_nix_tm_node_lvl(struct roc_nix *roc_nix, uint32_t node_id);
+int __roc_api roc_nix_tm_node_name_get(struct roc_nix *roc_nix,
+				       uint32_t node_id, char *buf,
+				       size_t buflen);
+
 /* MAC */
 int __roc_api roc_nix_mac_rxtx_start_stop(struct roc_nix *roc_nix, bool start);
 int __roc_api roc_nix_mac_link_event_start_stop(struct roc_nix *roc_nix,
drivers/common/cnxk/roc_nix_priv.h +14 -0
index 4773221..cee73ae 100644
@@ -326,14 +326,28 @@ int nix_tm_leaf_data_get(struct nix *nix, uint16_t sq, uint32_t *rr_quantum,
 int nix_tm_sq_flush_pre(struct roc_nix_sq *sq);
 int nix_tm_sq_flush_post(struct roc_nix_sq *sq);
 int nix_tm_smq_xoff(struct nix *nix, struct nix_tm_node *node, bool enable);
+int nix_tm_node_add(struct roc_nix *roc_nix, struct nix_tm_node *node);
+int nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
+		       enum roc_nix_tm_tree tree, bool free);
+int nix_tm_free_node_resource(struct nix *nix, struct nix_tm_node *node);
 int nix_tm_clear_path_xoff(struct nix *nix, struct nix_tm_node *node);
 
 /*
  * TM priv utils.
  */
+uint16_t nix_tm_lvl2nix(struct nix *nix, uint32_t lvl);
+uint16_t nix_tm_lvl2nix_tl1_root(uint32_t lvl);
+uint16_t nix_tm_lvl2nix_tl2_root(uint32_t lvl);
+uint16_t nix_tm_resource_avail(struct nix *nix, uint8_t hw_lvl, bool contig);
+int nix_tm_validate_prio(struct nix *nix, uint32_t lvl, uint32_t parent_id,
+			 uint32_t priority, enum roc_nix_tm_tree tree);
 struct nix_tm_node *nix_tm_node_search(struct nix *nix, uint32_t node_id,
 				       enum roc_nix_tm_tree tree);
+struct nix_tm_shaper_profile *nix_tm_shaper_profile_search(struct nix *nix,
+							   uint32_t id);
 uint8_t nix_tm_sw_xoff_prep(struct nix_tm_node *node, bool enable,
 			    volatile uint64_t *reg, volatile uint64_t *regval);
+struct nix_tm_node *nix_tm_node_alloc(void);
+void nix_tm_node_free(struct nix_tm_node *node);
 
 #endif /* _ROC_NIX_PRIV_H_ */
drivers/common/cnxk/roc_nix_tm.c +205 -0

223 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_ops.c +88 -0

91 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_utils.c +212 -0

227 lines not on this page · raw message

drivers/common/cnxk/version.map +7 -0
index 5e035d1..2bc50bf 100644
@@ -104,6 +104,13 @@ INTERNAL {
 	roc_nix_xstats_names_get;
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
+	roc_nix_tm_node_add;
+	roc_nix_tm_node_delete;
+	roc_nix_tm_node_get;
+	roc_nix_tm_node_lvl;
+	roc_nix_tm_node_name_get;
+	roc_nix_tm_node_next;
+	roc_nix_tm_node_pkt_mode_update;
 	roc_nix_tm_sq_aura_fc;
 	roc_nix_tm_sq_flush_spin;
 	roc_nix_unregister_cq_irqs;
Signature · 1 line
2.8.4
#255 lore raw

PATCH v5 34/52 common/cnxk: add nix tm shaper profile add support

In reply to Nithin Dabilpuram

From: Satha Rao <[email protected]>

Add support to add/delete/update shaper profile for a given NIX. Also add support to walk through existing shaper profiles.

---
 drivers/common/cnxk/roc_nix.h          |  25 +++++
 drivers/common/cnxk/roc_nix_priv.h     |   8 ++
 drivers/common/cnxk/roc_nix_tm.c       |  18 ++++
 drivers/common/cnxk/roc_nix_tm_ops.c   | 145 ++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm_utils.c | 167 +++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map        |   5 +
 6 files changed, 368 insertions(+)
drivers/common/cnxk/roc_nix.h +25 -0
index d656909..ea34cd2 100644
@@ -353,17 +353,42 @@ struct roc_nix_tm_node {
 	void (*free_fn)(void *node);
 };
 
+struct roc_nix_tm_shaper_profile {
+#define ROC_NIX_TM_SHAPER_PROFILE_SZ (128)
+	uint8_t reserved[ROC_NIX_TM_SHAPER_PROFILE_SZ];
+
+	uint32_t id;
+	uint64_t commit_rate;
+	uint64_t commit_sz;
+	uint64_t peak_rate;
+	uint64_t peak_sz;
+	int32_t pkt_len_adj;
+	bool pkt_mode;
+	/* Function to free this memory */
+	void (*free_fn)(void *profile);
+};
+
 int __roc_api roc_nix_tm_node_add(struct roc_nix *roc_nix,
 				  struct roc_nix_tm_node *roc_node);
 int __roc_api roc_nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
 				     bool free);
 int __roc_api roc_nix_tm_node_pkt_mode_update(struct roc_nix *roc_nix,
 					      uint32_t node_id, bool pkt_mode);
+int __roc_api roc_nix_tm_shaper_profile_add(
+	struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *profile);
+int __roc_api roc_nix_tm_shaper_profile_update(
+	struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *profile);
+int __roc_api roc_nix_tm_shaper_profile_delete(struct roc_nix *roc_nix,
+					       uint32_t id);
 
 struct roc_nix_tm_node *__roc_api roc_nix_tm_node_get(struct roc_nix *roc_nix,
 						      uint32_t node_id);
 struct roc_nix_tm_node *__roc_api
 roc_nix_tm_node_next(struct roc_nix *roc_nix, struct roc_nix_tm_node *__prev);
+struct roc_nix_tm_shaper_profile *__roc_api
+roc_nix_tm_shaper_profile_get(struct roc_nix *roc_nix, uint32_t profile_id);
+struct roc_nix_tm_shaper_profile *__roc_api roc_nix_tm_shaper_profile_next(
+	struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *__prev);
 
 /*
  * TM utilities API.
drivers/common/cnxk/roc_nix_priv.h +8 -0
index cee73ae..cd1eaa5 100644
@@ -331,6 +331,7 @@ int nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
 		       enum roc_nix_tm_tree tree, bool free);
 int nix_tm_free_node_resource(struct nix *nix, struct nix_tm_node *node);
 int nix_tm_clear_path_xoff(struct nix *nix, struct nix_tm_node *node);
+void nix_tm_clear_shaper_profiles(struct nix *nix);
 
 /*
  * TM priv utils.
@@ -347,7 +348,14 @@ struct nix_tm_shaper_profile *nix_tm_shaper_profile_search(struct nix *nix,
 							   uint32_t id);
 uint8_t nix_tm_sw_xoff_prep(struct nix_tm_node *node, bool enable,
 			    volatile uint64_t *reg, volatile uint64_t *regval);
+uint64_t nix_tm_shaper_profile_rate_min(struct nix *nix);
+uint64_t nix_tm_shaper_rate_conv(uint64_t value, uint64_t *exponent_p,
+				 uint64_t *mantissa_p, uint64_t *div_exp_p);
+uint64_t nix_tm_shaper_burst_conv(uint64_t value, uint64_t *exponent_p,
+				  uint64_t *mantissa_p);
 struct nix_tm_node *nix_tm_node_alloc(void);
 void nix_tm_node_free(struct nix_tm_node *node);
+struct nix_tm_shaper_profile *nix_tm_shaper_profile_alloc(void);
+void nix_tm_shaper_profile_free(struct nix_tm_shaper_profile *profile);
 
 #endif /* _ROC_NIX_PRIV_H_ */
drivers/common/cnxk/roc_nix_tm.c +18 -0
index f103e02..d2e2250 100644
@@ -5,6 +5,22 @@
 #include "roc_api.h"
 #include "roc_priv.h"
 
+void
+nix_tm_clear_shaper_profiles(struct nix *nix)
+{
+	struct nix_tm_shaper_profile *shaper_profile;
+
+	shaper_profile = TAILQ_FIRST(&nix->shaper_profile_list);
+	while (shaper_profile != NULL) {
+		if (shaper_profile->ref_cnt)
+			plt_warn("Shaper profile %u has non zero references",
+				 shaper_profile->id);
+		TAILQ_REMOVE(&nix->shaper_profile_list, shaper_profile, shaper);
+		nix_tm_shaper_profile_free(shaper_profile);
+		shaper_profile = TAILQ_FIRST(&nix->shaper_profile_list);
+	}
+}
+
 int
 nix_tm_node_add(struct roc_nix *roc_nix, struct nix_tm_node *node)
 {
@@ -532,6 +548,8 @@ nix_tm_conf_init(struct roc_nix *roc_nix)
 	int rc, i;
 
 	PLT_STATIC_ASSERT(sizeof(struct nix_tm_node) <= ROC_NIX_TM_NODE_SZ);
+	PLT_STATIC_ASSERT(sizeof(struct nix_tm_shaper_profile) <=
+			  ROC_NIX_TM_SHAPER_PROFILE_SZ);
 
 	nix->tm_flags = 0;
 	for (i = 0; i < ROC_NIX_TM_TREE_MAX; i++)
drivers/common/cnxk/roc_nix_tm_ops.c +145 -0

151 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_utils.c +167 -0

188 lines not on this page · raw message

drivers/common/cnxk/version.map +5 -0
index 2bc50bf..5bf8717 100644
@@ -111,6 +111,11 @@ INTERNAL {
 	roc_nix_tm_node_name_get;
 	roc_nix_tm_node_next;
 	roc_nix_tm_node_pkt_mode_update;
+	roc_nix_tm_shaper_profile_add;
+	roc_nix_tm_shaper_profile_delete;
+	roc_nix_tm_shaper_profile_get;
+	roc_nix_tm_shaper_profile_next;
+	roc_nix_tm_shaper_profile_update;
 	roc_nix_tm_sq_aura_fc;
 	roc_nix_tm_sq_flush_spin;
 	roc_nix_unregister_cq_irqs;
Signature · 1 line
2.8.4
#256 lore raw

PATCH v5 35/52 common/cnxk: add nix tm helper to alloc and free resource

In reply to Nithin Dabilpuram

Add TM helper API to estimate, alloc, assign, and free resources for a NIX LF / ethdev.

---
 drivers/common/cnxk/roc_nix.h          |   1 +
 drivers/common/cnxk/roc_nix_priv.h     |  16 ++
 drivers/common/cnxk/roc_nix_tm.c       | 461 +++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm_ops.c   |  11 +
 drivers/common/cnxk/roc_nix_tm_utils.c | 133 ++++++++++
 drivers/common/cnxk/version.map        |   1 +
 6 files changed, 623 insertions(+)
drivers/common/cnxk/roc_nix.h +1 -0
index ea34cd2..52e001c 100644
@@ -372,6 +372,7 @@ int __roc_api roc_nix_tm_node_add(struct roc_nix *roc_nix,
 				  struct roc_nix_tm_node *roc_node);
 int __roc_api roc_nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
 				     bool free);
+int __roc_api roc_nix_tm_free_resources(struct roc_nix *roc_nix, bool hw_only);
 int __roc_api roc_nix_tm_node_pkt_mode_update(struct roc_nix *roc_nix,
 					      uint32_t node_id, bool pkt_mode);
 int __roc_api roc_nix_tm_shaper_profile_add(
drivers/common/cnxk/roc_nix_priv.h +16 -0
index cd1eaa5..9384bdd 100644
@@ -330,8 +330,17 @@ int nix_tm_node_add(struct roc_nix *roc_nix, struct nix_tm_node *node);
 int nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
 		       enum roc_nix_tm_tree tree, bool free);
 int nix_tm_free_node_resource(struct nix *nix, struct nix_tm_node *node);
+int nix_tm_free_resources(struct roc_nix *roc_nix, uint32_t tree_mask,
+			  bool hw_only);
 int nix_tm_clear_path_xoff(struct nix *nix, struct nix_tm_node *node);
 void nix_tm_clear_shaper_profiles(struct nix *nix);
+int nix_tm_alloc_txschq(struct nix *nix, enum roc_nix_tm_tree tree);
+int nix_tm_assign_resources(struct nix *nix, enum roc_nix_tm_tree tree);
+int nix_tm_release_resources(struct nix *nix, uint8_t hw_lvl, bool contig,
+			     bool above_thresh);
+void nix_tm_copy_rsp_to_nix(struct nix *nix, struct nix_txsch_alloc_rsp *rsp);
+
+int nix_tm_update_parent_info(struct nix *nix, enum roc_nix_tm_tree tree);
 
 /*
  * TM priv utils.
@@ -348,11 +357,18 @@ struct nix_tm_shaper_profile *nix_tm_shaper_profile_search(struct nix *nix,
 							   uint32_t id);
 uint8_t nix_tm_sw_xoff_prep(struct nix_tm_node *node, bool enable,
 			    volatile uint64_t *reg, volatile uint64_t *regval);
+uint32_t nix_tm_check_rr(struct nix *nix, uint32_t parent_id,
+			 enum roc_nix_tm_tree tree, uint32_t *rr_prio,
+			 uint32_t *max_prio);
 uint64_t nix_tm_shaper_profile_rate_min(struct nix *nix);
 uint64_t nix_tm_shaper_rate_conv(uint64_t value, uint64_t *exponent_p,
 				 uint64_t *mantissa_p, uint64_t *div_exp_p);
 uint64_t nix_tm_shaper_burst_conv(uint64_t value, uint64_t *exponent_p,
 				  uint64_t *mantissa_p);
+bool nix_tm_child_res_valid(struct nix_tm_node_list *list,
+			    struct nix_tm_node *parent);
+uint16_t nix_tm_resource_estimate(struct nix *nix, uint16_t *schq_contig,
+				  uint16_t *schq, enum roc_nix_tm_tree tree);
 struct nix_tm_node *nix_tm_node_alloc(void);
 void nix_tm_node_free(struct nix_tm_node *node);
 struct nix_tm_shaper_profile *nix_tm_shaper_profile_alloc(void);
drivers/common/cnxk/roc_nix_tm.c +461 -0

485 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_ops.c +11 -0
index 896ddf2..1e952c4 100644
@@ -66,6 +66,17 @@ roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable)
 	return 0;
 }
 
+int
+roc_nix_tm_free_resources(struct roc_nix *roc_nix, bool hw_only)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+
+	if (nix->tm_flags & NIX_TM_HIERARCHY_ENA)
+		return -EBUSY;
+
+	return nix_tm_free_resources(roc_nix, BIT(ROC_NIX_TM_USER), hw_only);
+}
+
 static int
 nix_tm_shaper_profile_add(struct roc_nix *roc_nix,
 			  struct nix_tm_shaper_profile *profile, int skip_ins)
drivers/common/cnxk/roc_nix_tm_utils.c +133 -0

151 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index 5bf8717..3c79023 100644
@@ -104,6 +104,7 @@ INTERNAL {
 	roc_nix_xstats_names_get;
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
+	roc_nix_tm_free_resources;
 	roc_nix_tm_node_add;
 	roc_nix_tm_node_delete;
 	roc_nix_tm_node_get;
Signature · 1 line
2.8.4
#257 lore raw

PATCH v5 36/52 common/cnxk: add nix tm hierarchy enable/disable

In reply to Nithin Dabilpuram

Add support to enable or disable hierarchy along with allocating node HW resources such as shapers and schedulers and configuring them to match the user created or default hierarchy.

---
 drivers/common/cnxk/roc_nix.h          |   8 +
 drivers/common/cnxk/roc_nix_priv.h     |  16 ++
 drivers/common/cnxk/roc_nix_tm.c       | 147 ++++++++++++
 drivers/common/cnxk/roc_nix_tm_ops.c   | 234 +++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm_utils.c | 410 +++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map        |   2 +
 6 files changed, 817 insertions(+)
drivers/common/cnxk/roc_nix.h +8 -0
index 52e001c..7bf3435 100644
@@ -392,6 +392,14 @@ struct roc_nix_tm_shaper_profile *__roc_api roc_nix_tm_shaper_profile_next(
 	struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *__prev);
 
 /*
+ * TM hierarchy enable/disable API.
+ */
+int __roc_api roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix);
+int __roc_api roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix,
+					  enum roc_nix_tm_tree tree,
+					  bool xmit_enable);
+
+/*
  * TM utilities API.
  */
 int __roc_api roc_nix_tm_node_lvl(struct roc_nix *roc_nix, uint32_t node_id);
drivers/common/cnxk/roc_nix_priv.h +16 -0
index 9384bdd..5d54bd2 100644
@@ -340,7 +340,10 @@ int nix_tm_release_resources(struct nix *nix, uint8_t hw_lvl, bool contig,
 			     bool above_thresh);
 void nix_tm_copy_rsp_to_nix(struct nix *nix, struct nix_txsch_alloc_rsp *rsp);
 
+int nix_tm_txsch_reg_config(struct nix *nix, enum roc_nix_tm_tree tree);
 int nix_tm_update_parent_info(struct nix *nix, enum roc_nix_tm_tree tree);
+int nix_tm_sq_sched_conf(struct nix *nix, struct nix_tm_node *node,
+			 bool rr_quantum_only);
 
 /*
  * TM priv utils.
@@ -369,6 +372,19 @@ bool nix_tm_child_res_valid(struct nix_tm_node_list *list,
 			    struct nix_tm_node *parent);
 uint16_t nix_tm_resource_estimate(struct nix *nix, uint16_t *schq_contig,
 				  uint16_t *schq, enum roc_nix_tm_tree tree);
+uint8_t nix_tm_tl1_default_prep(uint32_t schq, volatile uint64_t *reg,
+				volatile uint64_t *regval);
+uint8_t nix_tm_topology_reg_prep(struct nix *nix, struct nix_tm_node *node,
+				 volatile uint64_t *reg,
+				 volatile uint64_t *regval,
+				 volatile uint64_t *regval_mask);
+uint8_t nix_tm_sched_reg_prep(struct nix *nix, struct nix_tm_node *node,
+			      volatile uint64_t *reg,
+			      volatile uint64_t *regval);
+uint8_t nix_tm_shaper_reg_prep(struct nix_tm_node *node,
+			       struct nix_tm_shaper_profile *profile,
+			       volatile uint64_t *reg,
+			       volatile uint64_t *regval);
 struct nix_tm_node *nix_tm_node_alloc(void);
 void nix_tm_node_free(struct nix_tm_node *node);
 struct nix_tm_shaper_profile *nix_tm_shaper_profile_alloc(void);
drivers/common/cnxk/roc_nix_tm.c +147 -0

159 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_ops.c +234 -0

237 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_utils.c +410 -0

434 lines not on this page · raw message

drivers/common/cnxk/version.map +2 -0
index 3c79023..2a1cc98 100644
@@ -105,6 +105,8 @@ INTERNAL {
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
 	roc_nix_tm_free_resources;
+	roc_nix_tm_hierarchy_disable;
+	roc_nix_tm_hierarchy_enable;
 	roc_nix_tm_node_add;
 	roc_nix_tm_node_delete;
 	roc_nix_tm_node_get;
Signature · 1 line
2.8.4
#258 lore raw

PATCH v5 37/52 common/cnxk: add nix tm support for internal hierarchy

In reply to Nithin Dabilpuram

Add support to create internal TM default hierarchy and ratelimit hierarchy and API to ratelimit SQ to a given rate. This will be used by cnxk ethdev driver's tx queue ratelimit op.

---
 drivers/common/cnxk/roc_nix.h        |   7 ++
 drivers/common/cnxk/roc_nix_priv.h   |   2 +
 drivers/common/cnxk/roc_nix_tm.c     | 156 +++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm_ops.c | 141 +++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map      |   3 +
 5 files changed, 309 insertions(+)
drivers/common/cnxk/roc_nix.h +7 -0
index 7bf3435..8992ad3 100644
@@ -330,6 +330,8 @@ enum roc_tm_node_level {
 /*
  * TM runtime hierarchy init API.
  */
+int __roc_api roc_nix_tm_init(struct roc_nix *roc_nix);
+void __roc_api roc_nix_tm_fini(struct roc_nix *roc_nix);
 int __roc_api roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable);
 int __roc_api roc_nix_tm_sq_flush_spin(struct roc_nix_sq *sq);
 
@@ -392,6 +394,11 @@ struct roc_nix_tm_shaper_profile *__roc_api roc_nix_tm_shaper_profile_next(
 	struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *__prev);
 
 /*
+ * TM ratelimit tree API.
+ */
+int __roc_api roc_nix_tm_rlimit_sq(struct roc_nix *roc_nix, uint16_t qid,
+				   uint64_t rate);
+/*
  * TM hierarchy enable/disable API.
  */
 int __roc_api roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix);
drivers/common/cnxk/roc_nix_priv.h +2 -0
index 5d54bd2..d9c32df 100644
@@ -326,6 +326,7 @@ int nix_tm_leaf_data_get(struct nix *nix, uint16_t sq, uint32_t *rr_quantum,
 int nix_tm_sq_flush_pre(struct roc_nix_sq *sq);
 int nix_tm_sq_flush_post(struct roc_nix_sq *sq);
 int nix_tm_smq_xoff(struct nix *nix, struct nix_tm_node *node, bool enable);
+int nix_tm_prepare_default_tree(struct roc_nix *roc_nix);
 int nix_tm_node_add(struct roc_nix *roc_nix, struct nix_tm_node *node);
 int nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
 		       enum roc_nix_tm_tree tree, bool free);
@@ -344,6 +345,7 @@ int nix_tm_txsch_reg_config(struct nix *nix, enum roc_nix_tm_tree tree);
 int nix_tm_update_parent_info(struct nix *nix, enum roc_nix_tm_tree tree);
 int nix_tm_sq_sched_conf(struct nix *nix, struct nix_tm_node *node,
 			 bool rr_quantum_only);
+int nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix);
 
 /*
  * TM priv utils.
drivers/common/cnxk/roc_nix_tm.c +156 -0

162 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_ops.c +141 -0

144 lines not on this page · raw message

drivers/common/cnxk/version.map +3 -0
index 2a1cc98..cb3ddb2 100644
@@ -104,9 +104,11 @@ INTERNAL {
 	roc_nix_xstats_names_get;
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
+	roc_nix_tm_fini;
 	roc_nix_tm_free_resources;
 	roc_nix_tm_hierarchy_disable;
 	roc_nix_tm_hierarchy_enable;
+	roc_nix_tm_init;
 	roc_nix_tm_node_add;
 	roc_nix_tm_node_delete;
 	roc_nix_tm_node_get;
@@ -114,6 +116,7 @@ INTERNAL {
 	roc_nix_tm_node_name_get;
 	roc_nix_tm_node_next;
 	roc_nix_tm_node_pkt_mode_update;
+	roc_nix_tm_rlimit_sq;
 	roc_nix_tm_shaper_profile_add;
 	roc_nix_tm_shaper_profile_delete;
 	roc_nix_tm_shaper_profile_get;
Signature · 1 line
2.8.4
#259 lore raw

PATCH v5 38/52 common/cnxk: add nix tm dynamic update support

In reply to Nithin Dabilpuram

Add support for dynamic node update of shaper profile, RR quantum and also support to suspend or resume an active TM node.

---
 drivers/common/cnxk/roc_nix.h        |  10 ++
 drivers/common/cnxk/roc_nix_tm_ops.c | 220 +++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map      |   3 +
 3 files changed, 233 insertions(+)
drivers/common/cnxk/roc_nix.h +10 -0
index 8992ad3..ad00efe 100644
@@ -375,6 +375,16 @@ int __roc_api roc_nix_tm_node_add(struct roc_nix *roc_nix,
 int __roc_api roc_nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
 				     bool free);
 int __roc_api roc_nix_tm_free_resources(struct roc_nix *roc_nix, bool hw_only);
+int __roc_api roc_nix_tm_node_suspend_resume(struct roc_nix *roc_nix,
+					     uint32_t node_id, bool suspend);
+int __roc_api roc_nix_tm_node_parent_update(struct roc_nix *roc_nix,
+					    uint32_t node_id,
+					    uint32_t new_parent_id,
+					    uint32_t priority, uint32_t weight);
+int __roc_api roc_nix_tm_node_shaper_update(struct roc_nix *roc_nix,
+					    uint32_t node_id,
+					    uint32_t profile_id,
+					    bool force_update);
 int __roc_api roc_nix_tm_node_pkt_mode_update(struct roc_nix *roc_nix,
 					      uint32_t node_id, bool pkt_mode);
 int __roc_api roc_nix_tm_shaper_profile_add(
drivers/common/cnxk/roc_nix_tm_ops.c +220 -0

226 lines not on this page · raw message

drivers/common/cnxk/version.map +3 -0
index cb3ddb2..a5eb17e 100644
@@ -115,7 +115,10 @@ INTERNAL {
 	roc_nix_tm_node_lvl;
 	roc_nix_tm_node_name_get;
 	roc_nix_tm_node_next;
+	roc_nix_tm_node_parent_update;
 	roc_nix_tm_node_pkt_mode_update;
+	roc_nix_tm_node_shaper_update;
+	roc_nix_tm_node_suspend_resume;
 	roc_nix_tm_rlimit_sq;
 	roc_nix_tm_shaper_profile_add;
 	roc_nix_tm_shaper_profile_delete;
Signature · 1 line
2.8.4
#260 lore raw

PATCH v5 39/52 common/cnxk: add nix tm debug support and misc utils

In reply to Nithin Dabilpuram

Add support to dump TM HW registers and hierarchy on error. This patch also adds support for misc utils such as API to query TM HW resource availability, resource pre-allocation and static priority support on root node.

---
 drivers/common/cnxk/roc_nix.h          |   9 +
 drivers/common/cnxk/roc_nix_debug.c    | 330 +++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix_tm.c       |   1 +
 drivers/common/cnxk/roc_nix_tm_ops.c   | 125 +++++++++++++
 drivers/common/cnxk/roc_nix_tm_utils.c |  18 ++
 drivers/common/cnxk/roc_utils.c        | 108 +++++++++++
 drivers/common/cnxk/version.map        |   6 +
 7 files changed, 597 insertions(+)
drivers/common/cnxk/roc_nix.h +9 -0
index ad00efe..b39f461 100644
@@ -291,6 +291,7 @@ void __roc_api roc_nix_cqe_dump(const struct nix_cqe_hdr_s *cq);
 void __roc_api roc_nix_rq_dump(struct roc_nix_rq *rq);
 void __roc_api roc_nix_cq_dump(struct roc_nix_cq *cq);
 void __roc_api roc_nix_sq_dump(struct roc_nix_sq *sq);
+void __roc_api roc_nix_tm_dump(struct roc_nix *roc_nix);
 void __roc_api roc_nix_dump(struct roc_nix *roc_nix);
 
 /* IRQ */
@@ -394,6 +395,10 @@ int __roc_api roc_nix_tm_shaper_profile_update(
 int __roc_api roc_nix_tm_shaper_profile_delete(struct roc_nix *roc_nix,
 					       uint32_t id);
 
+int __roc_api roc_nix_tm_prealloc_res(struct roc_nix *roc_nix, uint8_t lvl,
+				      uint16_t discontig, uint16_t contig);
+uint16_t __roc_api roc_nix_tm_leaf_cnt(struct roc_nix *roc_nix);
+
 struct roc_nix_tm_node *__roc_api roc_nix_tm_node_get(struct roc_nix *roc_nix,
 						      uint32_t node_id);
 struct roc_nix_tm_node *__roc_api
@@ -420,6 +425,10 @@ int __roc_api roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix,
  * TM utilities API.
  */
 int __roc_api roc_nix_tm_node_lvl(struct roc_nix *roc_nix, uint32_t node_id);
+bool __roc_api roc_nix_tm_root_has_sp(struct roc_nix *roc_nix);
+void __roc_api roc_nix_tm_rsrc_max(bool pf, uint16_t schq[ROC_TM_LVL_MAX]);
+int __roc_api roc_nix_tm_rsrc_count(struct roc_nix *roc_nix,
+				    uint16_t schq[ROC_TM_LVL_MAX]);
 int __roc_api roc_nix_tm_node_name_get(struct roc_nix *roc_nix,
 				       uint32_t node_id, char *buf,
 				       size_t buflen);
drivers/common/cnxk/roc_nix_debug.c +330 -0

342 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm.c +1 -0
index 9b328c9..ad54e17 100644
@@ -393,6 +393,7 @@ roc_nix_tm_sq_flush_spin(struct roc_nix_sq *sq)
 
 	return 0;
 exit:
+	roc_nix_tm_dump(sq->roc_nix);
 	roc_nix_queues_ctx_dump(sq->roc_nix);
 	return -EFAULT;
 }
drivers/common/cnxk/roc_nix_tm_ops.c +125 -0

134 lines not on this page · raw message

drivers/common/cnxk/roc_nix_tm_utils.c +18 -0
index b644716..1d7dd68 100644
@@ -868,6 +868,24 @@ nix_tm_resource_estimate(struct nix *nix, uint16_t *schq_contig, uint16_t *schq,
 	return cnt;
 }
 
+uint16_t
+roc_nix_tm_leaf_cnt(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tm_node_list *list;
+	struct nix_tm_node *node;
+	uint16_t leaf_cnt = 0;
+
+	/* Count leafs only in user list */
+	list = nix_tm_node_list(nix, ROC_NIX_TM_USER);
+	TAILQ_FOREACH(node, list, node) {
+		if (node->id < nix->nb_tx_queues)
+			leaf_cnt++;
+	}
+
+	return leaf_cnt;
+}
+
 int
 roc_nix_tm_node_lvl(struct roc_nix *roc_nix, uint32_t node_id)
 {
drivers/common/cnxk/roc_utils.c +108 -0

123 lines not on this page · raw message

drivers/common/cnxk/version.map +6 -0
index a5eb17e..a3f3059 100644
@@ -104,11 +104,13 @@ INTERNAL {
 	roc_nix_xstats_names_get;
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
+	roc_nix_tm_dump;
 	roc_nix_tm_fini;
 	roc_nix_tm_free_resources;
 	roc_nix_tm_hierarchy_disable;
 	roc_nix_tm_hierarchy_enable;
 	roc_nix_tm_init;
+	roc_nix_tm_leaf_cnt;
 	roc_nix_tm_node_add;
 	roc_nix_tm_node_delete;
 	roc_nix_tm_node_get;
@@ -119,7 +121,11 @@ INTERNAL {
 	roc_nix_tm_node_pkt_mode_update;
 	roc_nix_tm_node_shaper_update;
 	roc_nix_tm_node_suspend_resume;
+	roc_nix_tm_prealloc_res;
 	roc_nix_tm_rlimit_sq;
+	roc_nix_tm_root_has_sp;
+	roc_nix_tm_rsrc_count;
+	roc_nix_tm_rsrc_max;
 	roc_nix_tm_shaper_profile_add;
 	roc_nix_tm_shaper_profile_delete;
 	roc_nix_tm_shaper_profile_get;
Signature · 1 line
2.8.4
#261 lore raw

PATCH v5 40/52 common/cnxk: add npc support

In reply to Nithin Dabilpuram

From: Kiran Kumar K <[email protected]>

Adding initial support for programming NPC. NPC is Network Parser and CAM unit that provides Rx and Tx packet parsing and packet manipulation functionality on Marvell CN9K and CN10K SoC's. It is mapped to RTE Flow in DPDK.

---
 drivers/common/cnxk/roc_api.h      |   3 +
 drivers/common/cnxk/roc_npc.h      | 129 +++++++++++++
 drivers/common/cnxk/roc_npc_priv.h | 381 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_platform.c |   1 +
 drivers/common/cnxk/roc_platform.h |   2 +
 drivers/common/cnxk/roc_priv.h     |   3 +
 drivers/common/cnxk/roc_utils.c    |  25 +++
 drivers/common/cnxk/version.map    |   1 +
 8 files changed, 545 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npc.h
 create mode 100644 drivers/common/cnxk/roc_npc_priv.h
drivers/common/cnxk/roc_api.h +3 -0
index 718916d..8dc8eed 100644
@@ -82,6 +82,9 @@
 /* NPA */
 #include "roc_npa.h"
 
+/* NPC */
+#include "roc_npc.h"
+
 /* NIX */
 #include "roc_nix.h"
 
drivers/common/cnxk/roc_npc.h new file +129 -0

129 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h new file +381 -0

381 lines not on this page · raw message

drivers/common/cnxk/roc_platform.c +1 -0
index 2380540..a8c4ce7 100644
@@ -60,4 +60,5 @@ RTE_LOG_REGISTER(cnxk_logtype_base, pmd.cnxk.base, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_mbox, pmd.cnxk.mbox, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_npa, pmd.mempool.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_nix, pmd.net.cnxk, NOTICE);
+RTE_LOG_REGISTER(cnxk_logtype_npc, pmd.net.cnxk.flow, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_tm, pmd.net.cnxk.tm, NOTICE);
drivers/common/cnxk/roc_platform.h +2 -0
index da9c30b..cd7a5dc 100644
@@ -136,6 +136,7 @@ extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
 extern int cnxk_logtype_npa;
 extern int cnxk_logtype_nix;
+extern int cnxk_logtype_npc;
 extern int cnxk_logtype_tm;
 
 #define plt_err(fmt, args...)                                                  \
@@ -156,6 +157,7 @@ extern int cnxk_logtype_tm;
 #define plt_mbox_dbg(fmt, ...)	plt_dbg(mbox, fmt, ##__VA_ARGS__)
 #define plt_npa_dbg(fmt, ...)	plt_dbg(npa, fmt, ##__VA_ARGS__)
 #define plt_nix_dbg(fmt, ...)	plt_dbg(nix, fmt, ##__VA_ARGS__)
+#define plt_npc_dbg(fmt, ...)	plt_dbg(npc, fmt, ##__VA_ARGS__)
 #define plt_tm_dbg(fmt, ...)	plt_dbg(tm, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
drivers/common/cnxk/roc_priv.h +3 -0
index 7371785..2dcd9e7 100644
@@ -23,4 +23,7 @@
 /* NIX */
 #include "roc_nix_priv.h"
 
+/* NPC */
+#include "roc_npc_priv.h"
+
 #endif /* _ROC_PRIV_H_ */
drivers/common/cnxk/roc_utils.c +25 -0
index 986be3f..236b4ae 100644
@@ -14,16 +14,20 @@ roc_error_msg_get(int errorcode)
 	case NIX_AF_ERR_PARAM:
 	case NIX_ERR_PARAM:
 	case NPA_ERR_PARAM:
+	case NPC_ERR_PARAM:
 	case UTIL_ERR_PARAM:
 		err_msg = "Invalid parameter";
 		break;
 	case NIX_ERR_NO_MEM:
+	case NPC_ERR_NO_MEM:
 		err_msg = "Out of memory";
 		break;
 	case NIX_ERR_INVALID_RANGE:
+	case NPC_ERR_INVALID_RANGE:
 		err_msg = "Range is not supported";
 		break;
 	case NIX_ERR_INTERNAL:
+	case NPC_ERR_INTERNAL:
 		err_msg = "Internal error";
 		break;
 	case NIX_ERR_OP_NOTSUP:
@@ -104,6 +108,27 @@ roc_error_msg_get(int errorcode)
 	case NIX_ERR_NDC_SYNC:
 		err_msg = "NDC Sync failed";
 		break;
+	case NPC_ERR_INVALID_SPEC:
+		err_msg = "NPC invalid spec";
+		break;
+	case NPC_ERR_INVALID_MASK:
+		err_msg = "NPC  invalid mask";
+		break;
+	case NPC_ERR_INVALID_KEX:
+		err_msg = "NPC invalid key";
+		break;
+	case NPC_ERR_INVALID_SIZE:
+		err_msg = "NPC invalid key size";
+		break;
+	case NPC_ERR_ACTION_NOTSUP:
+		err_msg = "NPC action not supported";
+		break;
+	case NPC_ERR_PATTERN_NOTSUP:
+		err_msg = "NPC pattern not supported";
+		break;
+	case NPC_ERR_MCAM_ALLOC:
+		err_msg = "MCAM entry alloc failed";
+		break;
 	case NPA_ERR_ALLOC:
 		err_msg = "NPA alloc failed";
 		break;
drivers/common/cnxk/version.map +1 -0
index a3f3059..f961a23 100644
@@ -5,6 +5,7 @@ INTERNAL {
 	cnxk_logtype_mbox;
 	cnxk_logtype_nix;
 	cnxk_logtype_npa;
+	cnxk_logtype_npc;
 	cnxk_logtype_tm;
 	roc_clk_freq_get;
 	roc_error_msg_get;
Signature · 1 line
2.8.4
#262 lore raw

PATCH v5 41/52 common/cnxk: add npc helper API

In reply to Nithin Dabilpuram

From: Kiran Kumar K <[email protected]>

Adding NPC helper APIs to manage MCAM like pre allocating the mcam, configuring the rules, shifting mcam rules and preparing the data for mcam based on KEX.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_npc_priv.h  |  11 +
 drivers/common/cnxk/roc_npc_utils.c | 631 ++++++++++++++++++++++++++++++++++++
 3 files changed, 643 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npc_utils.c
drivers/common/cnxk/meson.build +1 -0
index b453364..6163179 100644
@@ -34,6 +34,7 @@ sources = files('roc_dev.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
+		'roc_npc_utils.c',
 		'roc_platform.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_npc_priv.h +11 -0
index 4e2418c..9434826 100644
@@ -378,4 +378,15 @@ roc_npc_to_npc_priv(struct roc_npc *npc)
 {
 	return (struct npc *)npc->reserved;
 }
+
+int npc_update_parse_state(struct npc_parse_state *pst,
+			   struct npc_parse_item_info *info, int lid, int lt,
+			   uint8_t flags);
+void npc_get_hw_supp_mask(struct npc_parse_state *pst,
+			  struct npc_parse_item_info *info, int lid, int lt);
+int npc_parse_item_basic(const struct roc_npc_item_info *item,
+			 struct npc_parse_item_info *info);
+int npc_check_preallocated_entry_cache(struct mbox *mbox,
+				       struct roc_npc_flow *flow,
+				       struct npc *npc);
 #endif /* _ROC_NPC_PRIV_H_ */
drivers/common/cnxk/roc_npc_utils.c new file +631 -0

631 lines not on this page · raw message

Signature · 1 line
2.8.4
#263 lore raw

PATCH v5 42/52 common/cnxk: add mcam utility API

In reply to Nithin Dabilpuram

From: Kiran Kumar K <[email protected]>

Adding mcam utility functions like reading KEX and reserving and writing mcam rules.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_npc_mcam.c | 708 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc_priv.h |  21 ++
 3 files changed, 730 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npc_mcam.c
drivers/common/cnxk/meson.build +1 -0
index 6163179..7c83050 100644
@@ -34,6 +34,7 @@ sources = files('roc_dev.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
+		'roc_npc_mcam.c',
 		'roc_npc_utils.c',
 		'roc_platform.c',
 		'roc_utils.c')
drivers/common/cnxk/roc_npc_mcam.c new file +708 -0

708 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +21 -0
index 9434826..13768f9 100644
@@ -379,6 +379,22 @@ roc_npc_to_npc_priv(struct roc_npc *npc)
 	return (struct npc *)npc->reserved;
 }
 
+int npc_mcam_free_counter(struct npc *npc, uint16_t ctr_id);
+int npc_mcam_read_counter(struct npc *npc, uint32_t ctr_id, uint64_t *count);
+int npc_mcam_clear_counter(struct npc *npc, uint32_t ctr_id);
+int npc_mcam_free_entry(struct npc *npc, uint32_t entry);
+int npc_mcam_free_all_entries(struct npc *npc);
+int npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow,
+			     struct npc_parse_state *pst);
+int npc_mcam_alloc_entry(struct npc *npc, struct roc_npc_flow *mcam,
+			 struct roc_npc_flow *ref_mcam, int prio,
+			 int *resp_count);
+int npc_mcam_alloc_entries(struct npc *npc, int ref_mcam, int *alloc_entry,
+			   int req_count, int prio, int *resp_count);
+
+int npc_mcam_ena_dis_entry(struct npc *npc, struct roc_npc_flow *mcam,
+			   bool enable);
+int npc_mcam_write_entry(struct npc *npc, struct roc_npc_flow *mcam);
 int npc_update_parse_state(struct npc_parse_state *pst,
 			   struct npc_parse_item_info *info, int lid, int lt,
 			   uint8_t flags);
@@ -386,7 +402,12 @@ void npc_get_hw_supp_mask(struct npc_parse_state *pst,
 			  struct npc_parse_item_info *info, int lid, int lt);
 int npc_parse_item_basic(const struct roc_npc_item_info *item,
 			 struct npc_parse_item_info *info);
+int npc_mcam_fetch_kex_cfg(struct npc *npc);
 int npc_check_preallocated_entry_cache(struct mbox *mbox,
 				       struct roc_npc_flow *flow,
 				       struct npc *npc);
+int npc_flow_free_all_resources(struct npc *npc);
+int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst,
+		     bool mcam_alloc);
+uint64_t npc_get_kex_capability(struct npc *npc);
 #endif /* _ROC_NPC_PRIV_H_ */
Signature · 1 line
2.8.4
#264 lore raw

PATCH v5 43/52 common/cnxk: add npc parsing API

In reply to Nithin Dabilpuram

From: Kiran Kumar K <[email protected]>

Adding npc parsing API support to parse different patterns and actions. Based on the pattern and actions ltype values will be chosen and mcam data will be configured at perticular offsets.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_npc_parse.c | 703 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc_priv.h  |  13 +
 3 files changed, 717 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npc_parse.c
drivers/common/cnxk/meson.build +1 -0
index 7c83050..9dd4c23 100644
@@ -35,6 +35,7 @@ sources = files('roc_dev.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
 		'roc_npc_mcam.c',
+		'roc_npc_parse.c',
 		'roc_npc_utils.c',
 		'roc_platform.c',
 		'roc_utils.c')
drivers/common/cnxk/roc_npc_parse.c new file +703 -0

703 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +13 -0
index 13768f9..dcf26c0 100644
@@ -402,11 +402,24 @@ void npc_get_hw_supp_mask(struct npc_parse_state *pst,
 			  struct npc_parse_item_info *info, int lid, int lt);
 int npc_parse_item_basic(const struct roc_npc_item_info *item,
 			 struct npc_parse_item_info *info);
+int npc_parse_meta_items(struct npc_parse_state *pst);
+int npc_parse_higig2_hdr(struct npc_parse_state *pst);
+int npc_parse_cpt_hdr(struct npc_parse_state *pst);
+int npc_parse_la(struct npc_parse_state *pst);
+int npc_parse_lb(struct npc_parse_state *pst);
+int npc_parse_lc(struct npc_parse_state *pst);
+int npc_parse_ld(struct npc_parse_state *pst);
+int npc_parse_le(struct npc_parse_state *pst);
+int npc_parse_lf(struct npc_parse_state *pst);
+int npc_parse_lg(struct npc_parse_state *pst);
+int npc_parse_lh(struct npc_parse_state *pst);
 int npc_mcam_fetch_kex_cfg(struct npc *npc);
 int npc_check_preallocated_entry_cache(struct mbox *mbox,
 				       struct roc_npc_flow *flow,
 				       struct npc *npc);
 int npc_flow_free_all_resources(struct npc *npc);
+const struct roc_npc_item_info *
+npc_parse_skip_void_and_any_items(const struct roc_npc_item_info *pattern);
 int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst,
 		     bool mcam_alloc);
 uint64_t npc_get_kex_capability(struct npc *npc);
Signature · 1 line
2.8.4
#265 lore raw

PATCH v5 44/52 common/cnxk: add npc init and fini support

In reply to Nithin Dabilpuram

From: Kiran Kumar K <[email protected]>

Adding support initialize and fini the npc. Further, adding APIs to create and destroy the npc rules.

---
 drivers/common/cnxk/meson.build |   1 +
 drivers/common/cnxk/roc_npc.c   | 713 ++++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc.h   |  40 +++
 drivers/common/cnxk/version.map |  16 +
 4 files changed, 770 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_npc.c
drivers/common/cnxk/meson.build +1 -0
index 9dd4c23..f12e344 100644
@@ -34,6 +34,7 @@ sources = files('roc_dev.c',
 		'roc_npa.c',
 		'roc_npa_debug.c',
 		'roc_npa_irq.c',
+		'roc_npc.c',
 		'roc_npc_mcam.c',
 		'roc_npc_parse.c',
 		'roc_npc_utils.c',
drivers/common/cnxk/roc_npc.c new file +713 -0

713 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +40 -0
index c841240..996739e 100644
@@ -126,4 +126,44 @@ struct roc_npc {
 	uint8_t reserved[ROC_NPC_MEM_SZ];
 } __plt_cache_aligned;
 
+int __roc_api roc_npc_init(struct roc_npc *roc_npc);
+int __roc_api roc_npc_fini(struct roc_npc *roc_npc);
+const char *__roc_api roc_npc_profile_name_get(struct roc_npc *roc_npc);
+
+struct roc_npc_flow *__roc_api
+roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
+		    const struct roc_npc_item_info pattern[],
+		    const struct roc_npc_action actions[], int *errcode);
+int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc,
+				   struct roc_npc_flow *flow);
+int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry);
+int __roc_api roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc,
+				       struct roc_npc_flow *mcam,
+				       struct roc_npc_flow *ref_mcam, int prio,
+				       int *resp_count);
+int __roc_api roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry,
+					 int *alloc_entry, int req_count,
+					 int priority, int *resp_count);
+int __roc_api roc_npc_mcam_ena_dis_entry(struct roc_npc *roc_npc,
+					 struct roc_npc_flow *mcam,
+					 bool enable);
+int __roc_api roc_npc_mcam_write_entry(struct roc_npc *roc_npc,
+				       struct roc_npc_flow *mcam);
+int __roc_api roc_npc_flow_parse(struct roc_npc *roc_npc,
+				 const struct roc_npc_attr *attr,
+				 const struct roc_npc_item_info pattern[],
+				 const struct roc_npc_action actions[],
+				 struct roc_npc_flow *flow);
+int __roc_api roc_npc_get_low_priority_mcam(struct roc_npc *roc_npc);
+
+int __roc_api roc_npc_mcam_free_counter(struct roc_npc *roc_npc,
+					uint16_t ctr_id);
+
+int __roc_api roc_npc_mcam_read_counter(struct roc_npc *roc_npc,
+					uint32_t ctr_id, uint64_t *count);
+int __roc_api roc_npc_mcam_clear_counter(struct roc_npc *roc_npc,
+					 uint32_t ctr_id);
+
+int __roc_api roc_npc_mcam_free_all_resources(struct roc_npc *roc_npc);
+
 #endif /* _ROC_NPC_H_ */
drivers/common/cnxk/version.map +16 -0
index f961a23..ed82b56 100644
@@ -154,6 +154,22 @@ INTERNAL {
 	roc_npa_pool_destroy;
 	roc_npa_pool_op_pc_reset;
 	roc_npa_pool_range_update_check;
+	roc_npc_fini;
+	roc_npc_flow_create;
+	roc_npc_flow_destroy;
+	roc_npc_flow_parse;
+	roc_npc_get_low_priority_mcam;
+	roc_npc_init;
+	roc_npc_mcam_alloc_entries;
+	roc_npc_mcam_alloc_entry;
+	roc_npc_mcam_clear_counter;
+	roc_npc_mcam_ena_dis_entry;
+	roc_npc_mcam_free_all_resources;
+	roc_npc_mcam_free_counter;
+	roc_npc_mcam_free_entry;
+	roc_npc_mcam_write_entry;
+	roc_npc_mcam_read_counter;
+	roc_npc_profile_name_get;
 	roc_plt_init;
 	roc_plt_init_cb_register;
 
Signature · 1 line
2.8.4
#266 lore raw

PATCH v5 45/52 common/cnxk: add base sso device support

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add SSO device init and fini which attach SSO LF resources to the RVU PF/VF and SSO HWS and HWGRP LFs alloc, free.

---
 drivers/common/cnxk/meson.build     |   1 +
 drivers/common/cnxk/roc_api.h       |   3 +
 drivers/common/cnxk/roc_idev.c      |  27 ++++
 drivers/common/cnxk/roc_idev_priv.h |   5 +
 drivers/common/cnxk/roc_nix.c       |   1 +
 drivers/common/cnxk/roc_platform.c  |   1 +
 drivers/common/cnxk/roc_platform.h  |   2 +
 drivers/common/cnxk/roc_priv.h      |   3 +
 drivers/common/cnxk/roc_sso.c       | 273 ++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_sso.h       |  34 +++++
 drivers/common/cnxk/roc_sso_priv.h  |  33 +++++
 drivers/common/cnxk/roc_utils.c     |   1 +
 drivers/common/cnxk/version.map     |   5 +
 13 files changed, 389 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_sso.c
 create mode 100644 drivers/common/cnxk/roc_sso.h
 create mode 100644 drivers/common/cnxk/roc_sso_priv.h
drivers/common/cnxk/meson.build +1 -0
index f12e344..79c8eaa 100644
@@ -39,5 +39,6 @@ sources = files('roc_dev.c',
 		'roc_npc_parse.c',
 		'roc_npc_utils.c',
 		'roc_platform.c',
+		'roc_sso.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_api.h +3 -0
index 8dc8eed..b7fc3b7 100644
@@ -88,6 +88,9 @@
 /* NIX */
 #include "roc_nix.h"
 
+/* SSO */
+#include "roc_sso.h"
+
 /* Utils */
 #include "roc_utils.h"
 
drivers/common/cnxk/roc_idev.c +27 -0
index a92ac6a..63cc040 100644
@@ -29,6 +29,7 @@ idev_get_cfg(void)
 void
 idev_set_defaults(struct idev_cfg *idev)
 {
+	idev->sso_pf_func = 0;
 	idev->npa = NULL;
 	idev->npa_pf_func = 0;
 	idev->max_pools = 128;
@@ -39,6 +40,32 @@ idev_set_defaults(struct idev_cfg *idev)
 }
 
 uint16_t
+idev_sso_pffunc_get(void)
+{
+	struct idev_cfg *idev;
+	uint16_t sso_pf_func;
+
+	idev = idev_get_cfg();
+	sso_pf_func = 0;
+	if (idev != NULL)
+		sso_pf_func = __atomic_load_n(&idev->sso_pf_func,
+					      __ATOMIC_ACQUIRE);
+
+	return sso_pf_func;
+}
+
+void
+idev_sso_pffunc_set(uint16_t sso_pf_func)
+{
+	struct idev_cfg *idev;
+
+	idev = idev_get_cfg();
+	if (idev != NULL)
+		__atomic_store_n(&idev->sso_pf_func, sso_pf_func,
+				 __ATOMIC_RELEASE);
+}
+
+uint16_t
 idev_npa_pffunc_get(void)
 {
 	struct idev_cfg *idev;
drivers/common/cnxk/roc_idev_priv.h +5 -0
index 36cdb33..ff10a90 100644
@@ -8,6 +8,7 @@
 /* Intra device related functions */
 struct npa_lf;
 struct idev_cfg {
+	uint16_t sso_pf_func;
 	uint16_t npa_pf_func;
 	struct npa_lf *npa;
 	uint16_t npa_refcnt;
@@ -28,6 +29,10 @@ uint32_t idev_npa_maxpools_get(void);
 void idev_npa_maxpools_set(uint32_t max_pools);
 uint16_t idev_npa_lf_active(struct dev *dev);
 
+/* idev sso */
+void idev_sso_pffunc_set(uint16_t sso_pf_func);
+uint16_t idev_sso_pffunc_get(void);
+
 /* idev lmt */
 uint16_t idev_lmt_pffunc_get(void);
 
drivers/common/cnxk/roc_nix.c +1 -0
index d6b288f..23d508b 100644
@@ -143,6 +143,7 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
 	req->rss_sz = nix->reta_sz;
 	req->rss_grps = ROC_NIX_RSS_GRPS;
 	req->npa_func = idev_npa_pffunc_get();
+	req->sso_func = idev_sso_pffunc_get();
 	req->rx_cfg = rx_cfg;
 
 	if (!roc_nix->rss_tag_as_xor)
drivers/common/cnxk/roc_platform.c +1 -0
index a8c4ce7..792ec0a 100644
@@ -61,4 +61,5 @@ RTE_LOG_REGISTER(cnxk_logtype_mbox, pmd.cnxk.mbox, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_npa, pmd.mempool.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_nix, pmd.net.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_npc, pmd.net.cnxk.flow, NOTICE);
+RTE_LOG_REGISTER(cnxk_logtype_sso, pmd.event.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_tm, pmd.net.cnxk.tm, NOTICE);
drivers/common/cnxk/roc_platform.h +2 -0
index cd7a5dc..e3a0bf4 100644
@@ -137,6 +137,7 @@ extern int cnxk_logtype_mbox;
 extern int cnxk_logtype_npa;
 extern int cnxk_logtype_nix;
 extern int cnxk_logtype_npc;
+extern int cnxk_logtype_sso;
 extern int cnxk_logtype_tm;
 
 #define plt_err(fmt, args...)                                                  \
@@ -158,6 +159,7 @@ extern int cnxk_logtype_tm;
 #define plt_npa_dbg(fmt, ...)	plt_dbg(npa, fmt, ##__VA_ARGS__)
 #define plt_nix_dbg(fmt, ...)	plt_dbg(nix, fmt, ##__VA_ARGS__)
 #define plt_npc_dbg(fmt, ...)	plt_dbg(npc, fmt, ##__VA_ARGS__)
+#define plt_sso_dbg(fmt, ...)	plt_dbg(sso, fmt, ##__VA_ARGS__)
 #define plt_tm_dbg(fmt, ...)	plt_dbg(tm, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
drivers/common/cnxk/roc_priv.h +3 -0
index 2dcd9e7..dd9d87a 100644
@@ -26,4 +26,7 @@
 /* NPC */
 #include "roc_npc_priv.h"
 
+/* SSO */
+#include "roc_sso_priv.h"
+
 #endif /* _ROC_PRIV_H_ */
drivers/common/cnxk/roc_sso.c new file +273 -0

273 lines not on this page · raw message

drivers/common/cnxk/roc_sso.h new file +34 -0
new file mode 100644
index 0000000..4f37f14
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _ROC_SSO_H_
+#define _ROC_SSO_H_
+
+struct roc_sso {
+	struct plt_pci_device *pci_dev;
+	/* Public data. */
+	uint16_t max_hwgrp;
+	uint16_t max_hws;
+	uint16_t nb_hwgrp;
+	uint8_t nb_hws;
+	uintptr_t lmt_base;
+	/* HW Const. */
+	uint32_t xae_waes;
+	uint32_t xaq_buf_size;
+	uint32_t iue;
+	/* Private data. */
+#define ROC_SSO_MEM_SZ (16 * 1024)
+	uint8_t reserved[ROC_SSO_MEM_SZ] __plt_cache_aligned;
+} __plt_cache_aligned;
+
+/* SSO device initialization */
+int __roc_api roc_sso_dev_init(struct roc_sso *roc_sso);
+int __roc_api roc_sso_dev_fini(struct roc_sso *roc_sso);
+
+/* SSO device configuration */
+int __roc_api roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws,
+				uint16_t nb_hwgrp);
+void __roc_api roc_sso_rsrc_fini(struct roc_sso *roc_sso);
+
+#endif /* _ROC_SSOW_H_ */
drivers/common/cnxk/roc_sso_priv.h new file +33 -0
new file mode 100644
index 0000000..1ab3f5b
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _ROC_SSO_PRIV_H_
+#define _ROC_SSO_PRIV_H_
+
+struct sso_rsrc {
+	uint16_t rsrc_id;
+	uint64_t base;
+};
+
+struct sso {
+	struct plt_pci_device *pci_dev;
+	struct dev dev;
+} __plt_cache_aligned;
+
+enum sso_err_status {
+	SSO_ERR_PARAM = -4096,
+};
+
+enum sso_lf_type {
+	SSO_LF_TYPE_HWS,
+	SSO_LF_TYPE_HWGRP,
+};
+
+static inline struct sso *
+roc_sso_to_sso_priv(struct roc_sso *roc_sso)
+{
+	return (struct sso *)&roc_sso->reserved[0];
+}
+
+#endif /* _ROC_SSO_PRIV_H_ */
drivers/common/cnxk/roc_utils.c +1 -0
index 236b4ae..542252f 100644
@@ -15,6 +15,7 @@ roc_error_msg_get(int errorcode)
 	case NIX_ERR_PARAM:
 	case NPA_ERR_PARAM:
 	case NPC_ERR_PARAM:
+	case SSO_ERR_PARAM:
 	case UTIL_ERR_PARAM:
 		err_msg = "Invalid parameter";
 		break;
drivers/common/cnxk/version.map +5 -0
index ed82b56..054c6bd 100644
@@ -6,6 +6,7 @@ INTERNAL {
 	cnxk_logtype_nix;
 	cnxk_logtype_npa;
 	cnxk_logtype_npc;
+	cnxk_logtype_sso;
 	cnxk_logtype_tm;
 	roc_clk_freq_get;
 	roc_error_msg_get;
@@ -172,6 +173,10 @@ INTERNAL {
 	roc_npc_profile_name_get;
 	roc_plt_init;
 	roc_plt_init_cb_register;
+	roc_sso_dev_fini;
+	roc_sso_dev_init;
+	roc_sso_rsrc_fini;
+	roc_sso_rsrc_init;
 
 	local: *;
 };
Signature · 1 line
2.8.4
#267 lore raw

PATCH v5 46/52 common/cnxk: add sso hws interface

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add SSO HWS interface for setting/unsetting links, retrieving base address and nanoseconds to getwork timeout.

---
 drivers/common/cnxk/roc_sso.c      | 128 ++++++++++++++++++++++++++++++++++++-
 drivers/common/cnxk/roc_sso.h      |   6 ++
 drivers/common/cnxk/roc_sso_priv.h |   3 +
 drivers/common/cnxk/version.map    |   4 ++
 4 files changed, 140 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_sso.c +127 -1
index 6875b08..ba9dc3b 100644
@@ -152,6 +152,104 @@ sso_rsrc_get(struct roc_sso *roc_sso)
 	return 0;
 }
 
+static void
+sso_hws_link_modify(uint8_t hws, uintptr_t base, struct plt_bitmap *bmp,
+		    uint16_t hwgrp[], uint16_t n, uint16_t enable)
+{
+	uint64_t reg;
+	int i, j, k;
+
+	i = 0;
+	while (n) {
+		uint64_t mask[4] = {
+			0x8000,
+			0x8000,
+			0x8000,
+			0x8000,
+		};
+
+		k = n % 4;
+		k = k ? k : 4;
+		for (j = 0; j < k; j++) {
+			mask[j] = hwgrp[i + j] | enable << 14;
+			enable ? plt_bitmap_set(bmp, hwgrp[i + j]) :
+				 plt_bitmap_clear(bmp, hwgrp[i + j]);
+			plt_sso_dbg("HWS %d Linked to HWGRP %d", hws,
+				    hwgrp[i + j]);
+		}
+
+		n -= j;
+		i += j;
+		reg = mask[0] | mask[1] << 16 | mask[2] << 32 | mask[3] << 48;
+		plt_write64(reg, base + SSOW_LF_GWS_GRPMSK_CHG);
+	}
+}
+
+/* Public Functions. */
+uintptr_t
+roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+
+	return dev->bar2 + (RVU_BLOCK_ADDR_SSOW << 20 | hws << 12);
+}
+
+uint64_t
+roc_sso_ns_to_gw(struct roc_sso *roc_sso, uint64_t ns)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	uint64_t current_us, current_ns, new_ns;
+	uintptr_t base;
+
+	base = dev->bar2 + (RVU_BLOCK_ADDR_SSOW << 20);
+	current_us = plt_read64(base + SSOW_LF_GWS_NW_TIM);
+	/* From HRM, table 14-19:
+	 * The SSOW_LF_GWS_NW_TIM[NW_TIM] period is specified in n-1 notation.
+	 */
+	current_us += 1;
+
+	/* From HRM, table 14-1:
+	 * SSOW_LF_GWS_NW_TIM[NW_TIM] specifies the minimum timeout. The SSO
+	 * hardware times out a GET_WORK request within 2 usec of the minimum
+	 * timeout specified by SSOW_LF_GWS_NW_TIM[NW_TIM].
+	 */
+	current_us += 2;
+	current_ns = current_us * 1E3;
+	new_ns = (ns - PLT_MIN(ns, current_ns));
+	new_ns = !new_ns ? 1 : new_ns;
+	return (new_ns * plt_tsc_hz()) / 1E9;
+}
+
+int
+roc_sso_hws_link(struct roc_sso *roc_sso, uint8_t hws, uint16_t hwgrp[],
+		 uint16_t nb_hwgrp)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	struct sso *sso;
+	uintptr_t base;
+
+	sso = roc_sso_to_sso_priv(roc_sso);
+	base = dev->bar2 + (RVU_BLOCK_ADDR_SSOW << 20 | hws << 12);
+	sso_hws_link_modify(hws, base, sso->link_map[hws], hwgrp, nb_hwgrp, 1);
+
+	return nb_hwgrp;
+}
+
+int
+roc_sso_hws_unlink(struct roc_sso *roc_sso, uint8_t hws, uint16_t hwgrp[],
+		   uint16_t nb_hwgrp)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	struct sso *sso;
+	uintptr_t base;
+
+	sso = roc_sso_to_sso_priv(roc_sso);
+	base = dev->bar2 + (RVU_BLOCK_ADDR_SSOW << 20 | hws << 12);
+	sso_hws_link_modify(hws, base, sso->link_map[hws], hwgrp, nb_hwgrp, 0);
+
+	return nb_hwgrp;
+}
+
 int
 roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp)
 {
@@ -225,8 +323,10 @@ int
 roc_sso_dev_init(struct roc_sso *roc_sso)
 {
 	struct plt_pci_device *pci_dev;
+	uint32_t link_map_sz;
 	struct sso *sso;
-	int rc;
+	void *link_mem;
+	int i, rc;
 
 	if (roc_sso == NULL || roc_sso->pci_dev == NULL)
 		return SSO_ERR_PARAM;
@@ -249,12 +349,38 @@ roc_sso_dev_init(struct roc_sso *roc_sso)
 	}
 	rc = -ENOMEM;
 
+	sso->link_map =
+		plt_zmalloc(sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
+	if (sso->link_map == NULL) {
+		plt_err("Failed to allocate memory for link_map array");
+		goto rsrc_fail;
+	}
+
+	link_map_sz = plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
+	sso->link_map_mem = plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
+	if (sso->link_map_mem == NULL) {
+		plt_err("Failed to get link_map memory");
+		goto rsrc_fail;
+	}
+
+	link_mem = sso->link_map_mem;
+	for (i = 0; i < roc_sso->max_hws; i++) {
+		sso->link_map[i] = plt_bitmap_init(roc_sso->max_hwgrp, link_mem,
+						   link_map_sz);
+		if (sso->link_map[i] == NULL) {
+			plt_err("Failed to allocate link map");
+			goto link_mem_free;
+		}
+		link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
+	}
 	idev_sso_pffunc_set(sso->dev.pf_func);
 	sso->pci_dev = pci_dev;
 	sso->dev.drv_inited = true;
 	roc_sso->lmt_base = sso->dev.lmt_base;
 
 	return 0;
+link_mem_free:
+	plt_free(sso->link_map_mem);
 rsrc_fail:
 	rc |= dev_fini(&sso->dev, pci_dev);
 fail:
drivers/common/cnxk/roc_sso.h +6 -0
index 4f37f14..7236045 100644
@@ -30,5 +30,11 @@ int __roc_api roc_sso_dev_fini(struct roc_sso *roc_sso);
 int __roc_api roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws,
 				uint16_t nb_hwgrp);
 void __roc_api roc_sso_rsrc_fini(struct roc_sso *roc_sso);
+uint64_t __roc_api roc_sso_ns_to_gw(struct roc_sso *roc_sso, uint64_t ns);
+int __roc_api roc_sso_hws_link(struct roc_sso *roc_sso, uint8_t hws,
+			       uint16_t hwgrp[], uint16_t nb_hwgrp);
+int __roc_api roc_sso_hws_unlink(struct roc_sso *roc_sso, uint8_t hws,
+				 uint16_t hwgrp[], uint16_t nb_hwgrp);
+uintptr_t __roc_api roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws);
 
 #endif /* _ROC_SSOW_H_ */
drivers/common/cnxk/roc_sso_priv.h +3 -0
index 1ab3f5b..ad35be1 100644
@@ -13,6 +13,9 @@ struct sso_rsrc {
 struct sso {
 	struct plt_pci_device *pci_dev;
 	struct dev dev;
+	/* SSO link mapping. */
+	struct plt_bitmap **link_map;
+	void *link_map_mem;
 } __plt_cache_aligned;
 
 enum sso_err_status {
drivers/common/cnxk/version.map +4 -0
index 054c6bd..8206f0f 100644
@@ -175,6 +175,10 @@ INTERNAL {
 	roc_plt_init_cb_register;
 	roc_sso_dev_fini;
 	roc_sso_dev_init;
+	roc_sso_hws_base_get;
+	roc_sso_hws_link;
+	roc_sso_hws_unlink;
+	roc_sso_ns_to_gw;
 	roc_sso_rsrc_fini;
 	roc_sso_rsrc_init;
 
Signature · 1 line
2.8.4
#268 lore raw

PATCH v5 47/52 common/cnxk: add sso hwgrp interface

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add SSO HWGRP interface for configuring XAQ pool, setting priority and internal HW buffer limits for each HWGRP.

---
 drivers/common/cnxk/roc_sso.c   | 110 ++++++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_sso.h   |  21 ++++++++
 drivers/common/cnxk/version.map |   6 +++
 3 files changed, 137 insertions(+)
drivers/common/cnxk/roc_sso.c +110 -0
index ba9dc3b..f4c4e5b 100644
@@ -194,6 +194,14 @@ roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws)
 	return dev->bar2 + (RVU_BLOCK_ADDR_SSOW << 20 | hws << 12);
 }
 
+uintptr_t
+roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+
+	return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
+}
+
 uint64_t
 roc_sso_ns_to_gw(struct roc_sso *roc_sso, uint64_t ns)
 {
@@ -251,6 +259,108 @@ roc_sso_hws_unlink(struct roc_sso *roc_sso, uint8_t hws, uint16_t hwgrp[],
 }
 
 int
+roc_sso_hwgrp_hws_link_status(struct roc_sso *roc_sso, uint8_t hws,
+			      uint16_t hwgrp)
+{
+	struct sso *sso;
+
+	sso = roc_sso_to_sso_priv(roc_sso);
+	return plt_bitmap_get(sso->link_map[hws], hwgrp);
+}
+
+int
+roc_sso_hwgrp_qos_config(struct roc_sso *roc_sso, struct roc_sso_hwgrp_qos *qos,
+			 uint8_t nb_qos, uint32_t nb_xaq)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	struct sso_grp_qos_cfg *req;
+	int i, rc;
+
+	for (i = 0; i < nb_qos; i++) {
+		uint8_t xaq_prcnt = qos[i].xaq_prcnt;
+		uint8_t iaq_prcnt = qos[i].iaq_prcnt;
+		uint8_t taq_prcnt = qos[i].taq_prcnt;
+
+		req = mbox_alloc_msg_sso_grp_qos_config(dev->mbox);
+		if (req == NULL) {
+			rc = mbox_process(dev->mbox);
+			if (rc < 0)
+				return rc;
+			req = mbox_alloc_msg_sso_grp_qos_config(dev->mbox);
+			if (req == NULL)
+				return -ENOSPC;
+		}
+		req->grp = qos[i].hwgrp;
+		req->xaq_limit = (nb_xaq * (xaq_prcnt ? xaq_prcnt : 100)) / 100;
+		req->taq_thr = (SSO_HWGRP_IAQ_MAX_THR_MASK *
+				(iaq_prcnt ? iaq_prcnt : 100)) /
+			       100;
+		req->iaq_thr = (SSO_HWGRP_TAQ_MAX_THR_MASK *
+				(taq_prcnt ? taq_prcnt : 100)) /
+			       100;
+	}
+
+	return mbox_process(dev->mbox);
+}
+
+int
+roc_sso_hwgrp_alloc_xaq(struct roc_sso *roc_sso, uint32_t npa_aura_id,
+			uint16_t hwgrps)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	struct sso_hw_setconfig *req;
+	int rc = -ENOSPC;
+
+	req = mbox_alloc_msg_sso_hw_setconfig(dev->mbox);
+	if (req == NULL)
+		return rc;
+	req->npa_pf_func = idev_npa_pffunc_get();
+	req->npa_aura_id = npa_aura_id;
+	req->hwgrps = hwgrps;
+
+	return mbox_process(dev->mbox);
+}
+
+int
+roc_sso_hwgrp_release_xaq(struct roc_sso *roc_sso, uint16_t hwgrps)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	struct sso_hw_xaq_release *req;
+
+	req = mbox_alloc_msg_sso_hw_release_xaq_aura(dev->mbox);
+	if (req == NULL)
+		return -EINVAL;
+	req->hwgrps = hwgrps;
+
+	return mbox_process(dev->mbox);
+}
+
+int
+roc_sso_hwgrp_set_priority(struct roc_sso *roc_sso, uint16_t hwgrp,
+			   uint8_t weight, uint8_t affinity, uint8_t priority)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_sso)->dev;
+	struct sso_grp_priority *req;
+	int rc = -ENOSPC;
+
+	req = mbox_alloc_msg_sso_grp_set_priority(dev->mbox);
+	if (req == NULL)
+		return rc;
+	req->grp = hwgrp;
+	req->weight = weight;
+	req->affinity = affinity;
+	req->priority = priority;
+
+	rc = mbox_process(dev->mbox);
+	if (rc < 0)
+		return rc;
+	plt_sso_dbg("HWGRP %d weight %d affinity %d priority %d", hwgrp, weight,
+		    affinity, priority);
+
+	return 0;
+}
+
+int
 roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp)
 {
 	struct sso_lf_alloc_rsp *rsp_hwgrp;
drivers/common/cnxk/roc_sso.h +21 -0
index 7236045..ed2713c 100644
@@ -5,6 +5,13 @@
 #ifndef _ROC_SSO_H_
 #define _ROC_SSO_H_
 
+struct roc_sso_hwgrp_qos {
+	uint16_t hwgrp;
+	uint8_t xaq_prcnt;
+	uint8_t iaq_prcnt;
+	uint8_t taq_prcnt;
+};
+
 struct roc_sso {
 	struct plt_pci_device *pci_dev;
 	/* Public data. */
@@ -30,11 +37,25 @@ int __roc_api roc_sso_dev_fini(struct roc_sso *roc_sso);
 int __roc_api roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws,
 				uint16_t nb_hwgrp);
 void __roc_api roc_sso_rsrc_fini(struct roc_sso *roc_sso);
+int __roc_api roc_sso_hwgrp_qos_config(struct roc_sso *roc_sso,
+				       struct roc_sso_hwgrp_qos *qos,
+				       uint8_t nb_qos, uint32_t nb_xaq);
+int __roc_api roc_sso_hwgrp_alloc_xaq(struct roc_sso *roc_sso,
+				      uint32_t npa_aura_id, uint16_t hwgrps);
+int __roc_api roc_sso_hwgrp_release_xaq(struct roc_sso *roc_sso,
+					uint16_t hwgrps);
+int __roc_api roc_sso_hwgrp_set_priority(struct roc_sso *roc_sso,
+					 uint16_t hwgrp, uint8_t weight,
+					 uint8_t affinity, uint8_t priority);
 uint64_t __roc_api roc_sso_ns_to_gw(struct roc_sso *roc_sso, uint64_t ns);
 int __roc_api roc_sso_hws_link(struct roc_sso *roc_sso, uint8_t hws,
 			       uint16_t hwgrp[], uint16_t nb_hwgrp);
 int __roc_api roc_sso_hws_unlink(struct roc_sso *roc_sso, uint8_t hws,
 				 uint16_t hwgrp[], uint16_t nb_hwgrp);
+int __roc_api roc_sso_hwgrp_hws_link_status(struct roc_sso *roc_sso,
+					    uint8_t hws, uint16_t hwgrp);
 uintptr_t __roc_api roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws);
+uintptr_t __roc_api roc_sso_hwgrp_base_get(struct roc_sso *roc_sso,
+					   uint16_t hwgrp);
 
 #endif /* _ROC_SSOW_H_ */
drivers/common/cnxk/version.map +6 -0
index 8206f0f..b4c6964 100644
@@ -175,6 +175,12 @@ INTERNAL {
 	roc_plt_init_cb_register;
 	roc_sso_dev_fini;
 	roc_sso_dev_init;
+	roc_sso_hwgrp_alloc_xaq;
+	roc_sso_hwgrp_base_get;
+	roc_sso_hwgrp_hws_link_status;
+	roc_sso_hwgrp_qos_config;
+	roc_sso_hwgrp_release_xaq;
+	roc_sso_hwgrp_set_priority;
 	roc_sso_hws_base_get;
 	roc_sso_hws_link;
 	roc_sso_hws_unlink;
Signature · 1 line
2.8.4
#269 lore raw

PATCH v5 48/52 common/cnxk: add sso irq support

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add support to registering and un-registering SSO HWS and HWGRP IRQs.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_sso.c      |  41 ++++++++++
 drivers/common/cnxk/roc_sso_irq.c  | 164 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_sso_priv.h |  14 ++++
 4 files changed, 220 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_sso_irq.c
drivers/common/cnxk/meson.build +1 -0
index 79c8eaa..d28e273 100644
@@ -40,5 +40,6 @@ sources = files('roc_dev.c',
 		'roc_npc_utils.c',
 		'roc_platform.c',
 		'roc_sso.c',
+		'roc_sso_irq.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_sso.c +41 -0

72 lines not on this page · raw message

drivers/common/cnxk/roc_sso_irq.c new file +164 -0

164 lines not on this page · raw message

drivers/common/cnxk/roc_sso_priv.h +14 -0
index ad35be1..5361d4f 100644
@@ -13,6 +13,12 @@ struct sso_rsrc {
 struct sso {
 	struct plt_pci_device *pci_dev;
 	struct dev dev;
+	/* Interrupt handler args. */
+	struct sso_rsrc hws_rsrc[MAX_RVU_BLKLF_CNT];
+	struct sso_rsrc hwgrp_rsrc[MAX_RVU_BLKLF_CNT];
+	/* MSIX offsets */
+	uint16_t hws_msix_offset[MAX_RVU_BLKLF_CNT];
+	uint16_t hwgrp_msix_offset[MAX_RVU_BLKLF_CNT];
 	/* SSO link mapping. */
 	struct plt_bitmap **link_map;
 	void *link_map_mem;
@@ -33,4 +39,12 @@ roc_sso_to_sso_priv(struct roc_sso *roc_sso)
 	return (struct sso *)&roc_sso->reserved[0];
 }
 
+/* SSO IRQ */
+int sso_register_irqs_priv(struct roc_sso *roc_sso,
+			   struct plt_intr_handle *handle, uint16_t nb_hws,
+			   uint16_t nb_hwgrp);
+void sso_unregister_irqs_priv(struct roc_sso *roc_sso,
+			      struct plt_intr_handle *handle, uint16_t nb_hws,
+			      uint16_t nb_hwgrp);
+
 #endif /* _ROC_SSO_PRIV_H_ */
Signature · 1 line
2.8.4
#270 lore raw

PATCH v5 49/52 common/cnxk: add sso debug support

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add sso debug dump support. This dumps all SSO LF register values to a given file handle.

---
 drivers/common/cnxk/meson.build     |  1 +
 drivers/common/cnxk/roc_sso.h       |  4 +++
 drivers/common/cnxk/roc_sso_debug.c | 68 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map     |  1 +
 4 files changed, 74 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_sso_debug.c
drivers/common/cnxk/meson.build +1 -0
index d28e273..e6e2ad3 100644
@@ -40,6 +40,7 @@ sources = files('roc_dev.c',
 		'roc_npc_utils.c',
 		'roc_platform.c',
 		'roc_sso.c',
+		'roc_sso_debug.c',
 		'roc_sso_irq.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_sso.h +4 -0
index ed2713c..f85799b 100644
@@ -58,4 +58,8 @@ uintptr_t __roc_api roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws);
 uintptr_t __roc_api roc_sso_hwgrp_base_get(struct roc_sso *roc_sso,
 					   uint16_t hwgrp);
 
+/* Debug */
+void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
+			    uint16_t hwgrp, FILE *f);
+
 #endif /* _ROC_SSOW_H_ */
drivers/common/cnxk/roc_sso_debug.c new file +68 -0

68 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index b4c6964..1e5e8ab 100644
@@ -175,6 +175,7 @@ INTERNAL {
 	roc_plt_init_cb_register;
 	roc_sso_dev_fini;
 	roc_sso_dev_init;
+	roc_sso_dump;
 	roc_sso_hwgrp_alloc_xaq;
 	roc_sso_hwgrp_base_get;
 	roc_sso_hwgrp_hws_link_status;
Signature · 1 line
2.8.4
#271 lore raw

PATCH v5 50/52 common/cnxk: add base tim device support

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add TIM device init, fini which are used to attach TIM LF resources to the RVU PF/VF and TIM LF alloc and free.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_api.h      |   3 +
 drivers/common/cnxk/roc_platform.c |   1 +
 drivers/common/cnxk/roc_platform.h |   2 +
 drivers/common/cnxk/roc_priv.h     |   3 +
 drivers/common/cnxk/roc_tim.c      | 263 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_tim.h      |  43 ++++++
 drivers/common/cnxk/roc_tim_priv.h |  21 +++
 drivers/common/cnxk/version.map    |   9 ++
 9 files changed, 346 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_tim.c
 create mode 100644 drivers/common/cnxk/roc_tim.h
 create mode 100644 drivers/common/cnxk/roc_tim_priv.h
drivers/common/cnxk/meson.build +1 -0
index e6e2ad3..1b02178 100644
@@ -42,5 +42,6 @@ sources = files('roc_dev.c',
 		'roc_sso.c',
 		'roc_sso_debug.c',
 		'roc_sso_irq.c',
+		'roc_tim.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_api.h +3 -0
index b7fc3b7..67f5d13 100644
@@ -91,6 +91,9 @@
 /* SSO */
 #include "roc_sso.h"
 
+/* TIM */
+#include "roc_tim.h"
+
 /* Utils */
 #include "roc_utils.h"
 
drivers/common/cnxk/roc_platform.c +1 -0
index 792ec0a..3999fce 100644
@@ -62,4 +62,5 @@ RTE_LOG_REGISTER(cnxk_logtype_npa, pmd.mempool.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_nix, pmd.net.cnxk, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_npc, pmd.net.cnxk.flow, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_sso, pmd.event.cnxk, NOTICE);
+RTE_LOG_REGISTER(cnxk_logtype_tim, pmd.event.cnxk.timer, NOTICE);
 RTE_LOG_REGISTER(cnxk_logtype_tm, pmd.net.cnxk.tm, NOTICE);
drivers/common/cnxk/roc_platform.h +2 -0
index e3a0bf4..97600e5 100644
@@ -138,6 +138,7 @@ extern int cnxk_logtype_npa;
 extern int cnxk_logtype_nix;
 extern int cnxk_logtype_npc;
 extern int cnxk_logtype_sso;
+extern int cnxk_logtype_tim;
 extern int cnxk_logtype_tm;
 
 #define plt_err(fmt, args...)                                                  \
@@ -160,6 +161,7 @@ extern int cnxk_logtype_tm;
 #define plt_nix_dbg(fmt, ...)	plt_dbg(nix, fmt, ##__VA_ARGS__)
 #define plt_npc_dbg(fmt, ...)	plt_dbg(npc, fmt, ##__VA_ARGS__)
 #define plt_sso_dbg(fmt, ...)	plt_dbg(sso, fmt, ##__VA_ARGS__)
+#define plt_tim_dbg(fmt, ...)	plt_dbg(tim, fmt, ##__VA_ARGS__)
 #define plt_tm_dbg(fmt, ...)	plt_dbg(tm, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
drivers/common/cnxk/roc_priv.h +3 -0
index dd9d87a..5e7564c 100644
@@ -29,4 +29,7 @@
 /* SSO */
 #include "roc_sso_priv.h"
 
+/* TIM */
+#include "roc_tim_priv.h"
+
 #endif /* _ROC_PRIV_H_ */
drivers/common/cnxk/roc_tim.c new file +263 -0

263 lines not on this page · raw message

drivers/common/cnxk/roc_tim.h new file +43 -0

43 lines not on this page · raw message

drivers/common/cnxk/roc_tim_priv.h new file +21 -0
new file mode 100644
index 0000000..08697f6
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _ROC_TIM_PRIV_H_
+#define _ROC_TIM_PRIV_H_
+
+struct tim {
+};
+
+enum tim_err_status {
+	TIM_ERR_PARAM = -5120,
+};
+
+static inline struct tim *
+roc_tim_to_tim_priv(struct roc_tim *roc_tim)
+{
+	return (struct tim *)&roc_tim->reserved[0];
+}
+
+#endif /* _ROC_TIM_PRIV_H_ */
drivers/common/cnxk/version.map +9 -0
index 1e5e8ab..5f2264f 100644
@@ -7,6 +7,7 @@ INTERNAL {
 	cnxk_logtype_npa;
 	cnxk_logtype_npc;
 	cnxk_logtype_sso;
+	cnxk_logtype_tim;
 	cnxk_logtype_tm;
 	roc_clk_freq_get;
 	roc_error_msg_get;
@@ -188,6 +189,14 @@ INTERNAL {
 	roc_sso_ns_to_gw;
 	roc_sso_rsrc_fini;
 	roc_sso_rsrc_init;
+	roc_tim_fini;
+	roc_tim_init;
+	roc_tim_lf_alloc;
+	roc_tim_lf_base_get;
+	roc_tim_lf_config;
+	roc_tim_lf_disable;
+	roc_tim_lf_enable;
+	roc_tim_lf_free;
 
 	local: *;
 };
Signature · 1 line
2.8.4
#272 lore raw

PATCH v5 51/52 common/cnxk: add tim irq support

In reply to Nithin Dabilpuram

From: Pavan Nikhilesh <[email protected]>

Add TIM LF IRQ register and un-register functions.

---
 drivers/common/cnxk/meson.build    |   1 +
 drivers/common/cnxk/roc_tim.c      |  51 ++++++++++++++++++
 drivers/common/cnxk/roc_tim_irq.c  | 104 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_tim_priv.h |   9 ++++
 4 files changed, 165 insertions(+)
 create mode 100644 drivers/common/cnxk/roc_tim_irq.c
drivers/common/cnxk/meson.build +1 -0
index 1b02178..4573d13 100644
@@ -43,5 +43,6 @@ sources = files('roc_dev.c',
 		'roc_sso_debug.c',
 		'roc_sso_irq.c',
 		'roc_tim.c',
+		'roc_tim_irq.c',
 		'roc_utils.c')
 includes += include_directories('../../bus/pci')
drivers/common/cnxk/roc_tim.c +51 -0

91 lines not on this page · raw message

drivers/common/cnxk/roc_tim_irq.c new file +104 -0

104 lines not on this page · raw message

drivers/common/cnxk/roc_tim_priv.h +9 -0
index 08697f6..cc083d2 100644
@@ -6,6 +6,7 @@
 #define _ROC_TIM_PRIV_H_
 
 struct tim {
+	uint16_t tim_msix_offsets[MAX_RVU_BLKLF_CNT];
 };
 
 enum tim_err_status {
@@ -18,4 +19,12 @@ roc_tim_to_tim_priv(struct roc_tim *roc_tim)
 	return (struct tim *)&roc_tim->reserved[0];
 }
 
+/* TIM IRQ*/
+int tim_register_irq_priv(struct roc_tim *roc_tim,
+			  struct plt_intr_handle *handle, uint8_t ring_id,
+			  uint16_t msix_offset);
+void tim_unregister_irq_priv(struct roc_tim *roc_tim,
+			     struct plt_intr_handle *handle, uint8_t ring_id,
+			     uint16_t msix_offset);
+
 #endif /* _ROC_TIM_PRIV_H_ */
Signature · 1 line
2.8.4
#273 lore raw

PATCH v5 52/52 common/cnxk: add support for RSS action in RTE Flow

In reply to Nithin Dabilpuram

From: Satheesh Paul <[email protected]>

Added support for allocating RSS group and setting it as action of an NPC rule for rte_flow.

---
 drivers/common/cnxk/roc_npc.c      | 159 +++++++++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc.h      |  20 +++++
 drivers/common/cnxk/roc_npc_mcam.c |   1 +
 drivers/common/cnxk/roc_npc_priv.h |   9 +++
 4 files changed, 189 insertions(+)
drivers/common/cnxk/roc_npc.c +159 -0
index c1ac3c7..abaef77 100644
@@ -634,6 +634,129 @@ roc_npc_flow_parse(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	return npc_program_mcam(npc, &parse_state, 0);
 }
 
+int
+npc_rss_free_grp_get(struct npc *npc, uint32_t *pos)
+{
+	struct plt_bitmap *bmap = npc->rss_grp_entries;
+
+	for (*pos = 0; *pos < ROC_NIX_RSS_GRPS; ++*pos) {
+		if (!plt_bitmap_get(bmap, *pos))
+			break;
+	}
+	return *pos < ROC_NIX_RSS_GRPS ? 0 : -1;
+}
+
+int
+npc_rss_action_configure(struct roc_npc *roc_npc,
+			 const struct roc_npc_action_rss *rss, uint8_t *alg_idx,
+			 uint32_t *rss_grp, uint32_t mcam_id)
+{
+	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
+	struct roc_nix *roc_nix = roc_npc->roc_nix;
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	uint32_t flowkey_cfg, rss_grp_idx, i, rem;
+	uint8_t key[ROC_NIX_RSS_KEY_LEN];
+	const uint8_t *key_ptr;
+	uint8_t flowkey_algx;
+	uint16_t *reta;
+	int rc;
+
+	rc = npc_rss_free_grp_get(npc, &rss_grp_idx);
+	/* RSS group :0 is not usable for flow rss action */
+	if (rc < 0 || rss_grp_idx == 0)
+		return -ENOSPC;
+
+	for (i = 0; i < rss->queue_num; i++) {
+		if (rss->queue[i] >= nix->nb_rx_queues) {
+			plt_err("queue id > max number of queues");
+			return -EINVAL;
+		}
+	}
+
+	*rss_grp = rss_grp_idx;
+
+	if (rss->key == NULL) {
+		roc_nix_rss_key_default_fill(roc_nix, key);
+		key_ptr = key;
+	} else {
+		key_ptr = rss->key;
+	}
+
+	roc_nix_rss_key_set(roc_nix, key_ptr);
+
+	/* If queue count passed in the rss action is less than
+	 * HW configured reta size, replicate rss action reta
+	 * across HW reta table.
+	 */
+	reta = nix->reta[rss_grp_idx];
+
+	if (rss->queue_num > nix->reta_sz) {
+		plt_err("too many queues for RSS context");
+		return -ENOTSUP;
+	}
+
+	for (i = 0; i < (nix->reta_sz / rss->queue_num); i++)
+		memcpy(reta + i * rss->queue_num, rss->queue,
+		       sizeof(uint16_t) * rss->queue_num);
+
+	rem = nix->reta_sz % rss->queue_num;
+	if (rem)
+		memcpy(&reta[i * rss->queue_num], rss->queue,
+		       rem * sizeof(uint16_t));
+
+	rc = roc_nix_rss_reta_set(roc_nix, *rss_grp, reta);
+	if (rc) {
+		plt_err("Failed to init rss table rc = %d", rc);
+		return rc;
+	}
+
+	flowkey_cfg = roc_npc->flowkey_cfg_state;
+
+	rc = roc_nix_rss_flowkey_set(roc_nix, &flowkey_algx, flowkey_cfg,
+				     *rss_grp, mcam_id);
+	if (rc) {
+		plt_err("Failed to set rss hash function rc = %d", rc);
+		return rc;
+	}
+
+	*alg_idx = flowkey_algx;
+
+	plt_bitmap_set(npc->rss_grp_entries, *rss_grp);
+
+	return 0;
+}
+
+int
+npc_rss_action_program(struct roc_npc *roc_npc,
+		       const struct roc_npc_action actions[],
+		       struct roc_npc_flow *flow)
+{
+	const struct roc_npc_action_rss *rss;
+	uint32_t rss_grp;
+	uint8_t alg_idx;
+	int rc;
+
+	for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) {
+		if (actions->type == ROC_NPC_ACTION_TYPE_RSS) {
+			rss = (const struct roc_npc_action_rss *)actions->conf;
+			rc = npc_rss_action_configure(roc_npc, rss, &alg_idx,
+						      &rss_grp, flow->mcam_id);
+			if (rc)
+				return rc;
+
+			flow->npc_action &= (~(0xfULL));
+			flow->npc_action |= NIX_RX_ACTIONOP_RSS;
+			flow->npc_action |=
+				((uint64_t)(alg_idx & NPC_RSS_ACT_ALG_MASK)
+				 << NPC_RSS_ACT_ALG_OFFSET) |
+				((uint64_t)(rss_grp & NPC_RSS_ACT_GRP_MASK)
+				 << NPC_RSS_ACT_GRP_OFFSET);
+			break;
+		}
+	}
+	return 0;
+}
+
 struct roc_npc_flow *
 roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		    const struct roc_npc_item_info pattern[],
@@ -666,6 +789,12 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		goto err_exit;
 	}
 
+	rc = npc_rss_action_program(roc_npc, actions, flow);
+	if (rc != 0) {
+		*errcode = rc;
+		goto set_rss_failed;
+	}
+
 	list = &npc->flow_list[flow->priority];
 	/* List in ascending order of mcam entries */
 	TAILQ_FOREACH(flow_iter, list, next) {
@@ -678,12 +807,36 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	TAILQ_INSERT_TAIL(list, flow, next);
 	return flow;
 
+set_rss_failed:
+	rc = npc_mcam_free_entry(npc, flow->mcam_id);
+	if (rc != 0) {
+		*errcode = rc;
+		plt_free(flow);
+		return NULL;
+	}
 err_exit:
 	plt_free(flow);
 	return NULL;
 }
 
 int
+npc_rss_group_free(struct npc *npc, struct roc_npc_flow *flow)
+{
+	uint32_t rss_grp;
+
+	if ((flow->npc_action & 0xF) == NIX_RX_ACTIONOP_RSS) {
+		rss_grp = (flow->npc_action >> NPC_RSS_ACT_GRP_OFFSET) &
+			  NPC_RSS_ACT_GRP_MASK;
+		if (rss_grp == 0 || rss_grp >= npc->rss_grps)
+			return -EINVAL;
+
+		plt_bitmap_clear(npc->rss_grp_entries, rss_grp);
+	}
+
+	return 0;
+}
+
+int
 roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
 {
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
@@ -699,6 +852,12 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
 			return NPC_ERR_PARAM;
 	}
 
+	rc = npc_rss_group_free(npc, flow);
+	if (rc != 0) {
+		plt_err("Failed to free rss action rc = %d", rc);
+		return rc;
+	}
+
 	rc = npc_mcam_free_entry(npc, flow->mcam_id);
 	if (rc != 0)
 		return rc;
drivers/common/cnxk/roc_npc.h +20 -0
index 996739e..223c4ba 100644
@@ -106,6 +106,24 @@ struct roc_npc_flow {
 	TAILQ_ENTRY(roc_npc_flow) next;
 };
 
+enum roc_npc_rss_hash_function {
+	ROC_NPC_RSS_HASH_FUNCTION_DEFAULT = 0,
+	ROC_NPC_RSS_HASH_FUNCTION_TOEPLITZ,   /**< Toeplitz */
+	ROC_NPC_RSS_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
+	ROC_NPC_RSS_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+	ROC_NPC_RSS_HASH_FUNCTION_MAX,
+};
+
+struct roc_npc_action_rss {
+	enum roc_npc_rss_hash_function func;
+	uint32_t level;
+	uint64_t types;	       /**< Specific RSS hash types (see ETH_RSS_*). */
+	uint32_t key_len;      /**< Hash key length in bytes. */
+	uint32_t queue_num;    /**< Number of entries in @p queue. */
+	const uint8_t *key;    /**< Hash key. */
+	const uint16_t *queue; /**< Queue indices to use. */
+};
+
 enum roc_npc_intf {
 	ROC_NPC_INTF_RX = 0,
 	ROC_NPC_INTF_TX = 1,
@@ -121,6 +139,8 @@ struct roc_npc {
 	uint16_t pf_func;
 	uint64_t kex_capability;
 	uint64_t rx_parse_nibble;
+	/* Parsed RSS Flowkey cfg for current flow being created */
+	uint32_t flowkey_cfg_state;
 
 #define ROC_NPC_MEM_SZ (5 * 1024)
 	uint8_t reserved[ROC_NPC_MEM_SZ];
drivers/common/cnxk/roc_npc_mcam.c +1 -0
index 572c52d..ff0676d 100644
@@ -692,6 +692,7 @@ npc_flow_free_all_resources(struct npc *npc)
 	/* Free any MCAM counters and delete flow list */
 	for (idx = 0; idx < npc->flow_max_priority; idx++) {
 		while ((flow = TAILQ_FIRST(&npc->flow_list[idx])) != NULL) {
+			npc_rss_group_free(npc, flow);
 			if (flow->ctr_id != NPC_COUNTER_NONE)
 				rc |= npc_mcam_free_counter(npc, flow->ctr_id);
 
drivers/common/cnxk/roc_npc_priv.h +9 -0
index dcf26c0..8bc5bac 100644
@@ -423,4 +423,13 @@ npc_parse_skip_void_and_any_items(const struct roc_npc_item_info *pattern);
 int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst,
 		     bool mcam_alloc);
 uint64_t npc_get_kex_capability(struct npc *npc);
+int npc_rss_free_grp_get(struct npc *npc, uint32_t *grp);
+int npc_rss_action_configure(struct roc_npc *roc_npc,
+			     const struct roc_npc_action_rss *rss,
+			     uint8_t *alg_idx, uint32_t *rss_grp,
+			     uint32_t mcam_id);
+int npc_rss_action_program(struct roc_npc *roc_npc,
+			   const struct roc_npc_action actions[],
+			   struct roc_npc_flow *flow);
+int npc_rss_group_free(struct npc *npc, struct roc_npc_flow *flow);
 #endif /* _ROC_NPC_PRIV_H_ */
Signature · 1 line
2.8.4
#274 lore raw
In reply to Nithin Dabilpuram
Quoted 10 lines · Nithin Dabilpuram

This patchset adds initial support for common code for Marvell CN10K SoC. Based on this common 'cnxk' driver, new PMD's such as 'net/cnxk', 'mempool/cnxk', 'event/cnxk' etc, will be added later on.

Initially 'cnxk' drivers will only support Marvell CN106XX SoC. In future, when code is ready, CN9K/octeontx2 will also be supported by the same set of drivers and 'common/octeontx2' and its associated drivers will be deprecated.

Series applied to dpdk-next-net-mrvl/for-dpdk-main. Thanks.

Quoted 254 lines

Ashwin Sekhar T K (8):
common/cnxk: add roc plt init callback support common/cnxk: add base npa device support common/cnxk: add npa irq support common/cnxk: add npa debug support common/cnxk: add npa pool HW ops common/cnxk: add npa bulk alloc/free support common/cnxk: add npa performance counter support common/cnxk: add npa batch alloc/free support

Jerin Jacob (14):
common/cnxk: add build infrastructre and HW definition common/cnxk: add model init and IO handling API common/cnxk: add interrupt helper API common/cnxk: add mbox request and response definitions common/cnxk: add mailbox base infra common/cnxk: add base device class common/cnxk: add VF support to base device class common/cnxk: add base nix support common/cnxk: add nix irq support
common/cnxk: add nix Rx queue management API common/cnxk: add nix Tx queue management API common/cnxk: add nix RSS support
common/cnxk: add nix stats support common/cnxk: add nix debug dump support

Kiran Kumar K (5):
common/cnxk: add npc support
common/cnxk: add npc helper API
common/cnxk: add mcam utility API
common/cnxk: add npc parsing API
common/cnxk: add npc init and fini support

Nithin Dabilpuram (8):
doc: add Marvell CNXK platform guide common/cnxk: add nix traffic management base support common/cnxk: add nix tm support to add/delete node common/cnxk: add nix tm helper to alloc and free resource common/cnxk: add nix tm hierarchy enable/disable common/cnxk: add nix tm support for internal hierarchy common/cnxk: add nix tm dynamic update support common/cnxk: add nix tm debug support and misc utils

Pavan Nikhilesh (7):
common/cnxk: add base sso device support
common/cnxk: add sso hws interface
common/cnxk: add sso hwgrp interface
common/cnxk: add sso irq support
common/cnxk: add sso debug support
common/cnxk: add base tim device support
common/cnxk: add tim irq support

Satha Rao (2):
common/cnxk: add support for nix extended stats common/cnxk: add nix tm shaper profile add support

Satheesh Paul (1):
common/cnxk: add support for RSS action in RTE Flow

Sunil Kumar Kori (6):
common/cnxk: add nix MAC operations support
common/cnxk: add nix specific npc operations
common/cnxk: add nix ptp support
common/cnxk: add VLAN filter support
common/cnxk: add nix flow control support
common/cnxk: add nix LSO support and misc utils

Vidya Sagar Velumuri (1):
common/cnxk: add nix inline IPsec config API

v5:
- Fixed naming issues in patch 04/52 and removed
RTE_ASSERT()
- Sync roc_mbox.h with kernel driver.

v4:
- Added entry to release notes. Fixed checkpatch issues
- Add plt callback for init by
"common/cnxk: add roc plt init callback support" replacing "common/cnxk: add npa lf init/fini callback support" to fix multi-process related failures.
- Fix supported SoC list to include CNF105xx

v3:
- Disable build for all except linux 64-bit.

v2:
- Added PART_95O to models supported
- Addressed comments from Jerin with respect to patch split and documentation
- Fixed a bug is lso utils and added get and custom fmt setup
- Handled rss action as well for rte flow rule
- Fixed issue with sso hws hwgrp link setup
- Renamed plt_init to roc_plt_init
- Disabled windows compilation

 MAINTAINERS                                        |    9 +
 doc/guides/platform/cnxk.rst                       |  579 ++++
 .../img/cnxk_packet_flow_hw_accelerators.svg       | 2795 ++++++++++++++++++++
 .../platform/img/cnxk_resource_virtualization.svg  | 2428 +++++++++++++++++
 doc/guides/platform/index.rst                      |    1 +
 doc/guides/rel_notes/release_21_05.rst             |    9 +
 drivers/common/cnxk/hw/nix.h                       | 2191 +++++++++++++++
 drivers/common/cnxk/hw/npa.h                       |  376 +++
 drivers/common/cnxk/hw/npc.h                       |  525 ++++
 drivers/common/cnxk/hw/rvu.h                       |  222 ++
 drivers/common/cnxk/hw/sdp.h                       |  182 ++
 drivers/common/cnxk/hw/sso.h                       |  233 ++
 drivers/common/cnxk/hw/ssow.h                      |   70 +
 drivers/common/cnxk/hw/tim.h                       |   49 +
 drivers/common/cnxk/meson.build                    |   48 +
 drivers/common/cnxk/roc_api.h                      |  103 +
 drivers/common/cnxk/roc_bitfield.h                 |   15 +
 drivers/common/cnxk/roc_bits.h                     |   32 +
 drivers/common/cnxk/roc_dev.c                      | 1190 +++++++++
 drivers/common/cnxk/roc_dev_priv.h                 |  107 +
 drivers/common/cnxk/roc_idev.c                     |  184 ++
 drivers/common/cnxk/roc_idev.h                     |   17 +
 drivers/common/cnxk/roc_idev_priv.h                |   39 +
 drivers/common/cnxk/roc_io.h                       |  187 ++
 drivers/common/cnxk/roc_io_generic.h               |  122 +
 drivers/common/cnxk/roc_irq.c                      |  249 ++
 drivers/common/cnxk/roc_mbox.c                     |  483 ++++
 drivers/common/cnxk/roc_mbox.h                     | 1766 +++++++++++++
 drivers/common/cnxk/roc_mbox_priv.h                |  215 ++
 drivers/common/cnxk/roc_model.c                    |  204 ++
 drivers/common/cnxk/roc_model.h                    |  128 +
 drivers/common/cnxk/roc_nix.c                      |  439 +++
 drivers/common/cnxk/roc_nix.h                      |  592 +++++
 drivers/common/cnxk/roc_nix_debug.c                | 1151 ++++++++
 drivers/common/cnxk/roc_nix_fc.c                   |  251 ++
 drivers/common/cnxk/roc_nix_irq.c                  |  495 ++++
 drivers/common/cnxk/roc_nix_mac.c                  |  298 +++
 drivers/common/cnxk/roc_nix_mcast.c                |   98 +
 drivers/common/cnxk/roc_nix_npc.c                  |  103 +
 drivers/common/cnxk/roc_nix_ops.c                  |  438 +++
 drivers/common/cnxk/roc_nix_priv.h                 |  395 +++
 drivers/common/cnxk/roc_nix_ptp.c                  |  122 +
 drivers/common/cnxk/roc_nix_queue.c                |  863 ++++++
 drivers/common/cnxk/roc_nix_rss.c                  |  220 ++
 drivers/common/cnxk/roc_nix_stats.c                |  411 +++
 drivers/common/cnxk/roc_nix_tm.c                   | 1385 ++++++++++
 drivers/common/cnxk/roc_nix_tm_ops.c               | 1031 ++++++++
 drivers/common/cnxk/roc_nix_tm_utils.c             | 1002 +++++++
 drivers/common/cnxk/roc_nix_vlan.c                 |  205 ++
 drivers/common/cnxk/roc_nix_xstats.h               |  204 ++
 drivers/common/cnxk/roc_npa.c                      |  796 ++++++
 drivers/common/cnxk/roc_npa.h                      |  653 +++++
 drivers/common/cnxk/roc_npa_debug.c                |  184 ++
 drivers/common/cnxk/roc_npa_irq.c                  |  298 +++
 drivers/common/cnxk/roc_npa_priv.h                 |   63 +
 drivers/common/cnxk/roc_npc.c                      |  872 ++++++
 drivers/common/cnxk/roc_npc.h                      |  189 ++
 drivers/common/cnxk/roc_npc_mcam.c                 |  709 +++++
 drivers/common/cnxk/roc_npc_parse.c                |  703 +++++
 drivers/common/cnxk/roc_npc_priv.h                 |  435 +++
 drivers/common/cnxk/roc_npc_utils.c                |  631 +++++
 drivers/common/cnxk/roc_platform.c                 |   66 +
 drivers/common/cnxk/roc_platform.h                 |  194 ++
 drivers/common/cnxk/roc_priv.h                     |   35 +
 drivers/common/cnxk/roc_sso.c                      |  550 ++++
 drivers/common/cnxk/roc_sso.h                      |   65 +
 drivers/common/cnxk/roc_sso_debug.c                |   68 +
 drivers/common/cnxk/roc_sso_irq.c                  |  164 ++
 drivers/common/cnxk/roc_sso_priv.h                 |   50 +
 drivers/common/cnxk/roc_tim.c                      |  314 +++
 drivers/common/cnxk/roc_tim.h                      |   43 +
 drivers/common/cnxk/roc_tim_irq.c                  |  104 +
 drivers/common/cnxk/roc_tim_priv.h                 |   30 +
 drivers/common/cnxk/roc_util_priv.h                |   14 +
 drivers/common/cnxk/roc_utils.c                    |  239 ++
 drivers/common/cnxk/roc_utils.h                    |   15 +
 drivers/common/cnxk/version.map                    |  202 ++
 drivers/meson.build                                |    1 +
 78 files changed, 32148 insertions(+)
 create mode 100644 doc/guides/platform/cnxk.rst
 create mode 100644 doc/guides/platform/img/cnxk_packet_flow_hw_accelerators.svg
 create mode 100644 doc/guides/platform/img/cnxk_resource_virtualization.svg
 create mode 100644 drivers/common/cnxk/hw/nix.h
 create mode 100644 drivers/common/cnxk/hw/npa.h
 create mode 100644 drivers/common/cnxk/hw/npc.h
 create mode 100644 drivers/common/cnxk/hw/rvu.h
 create mode 100644 drivers/common/cnxk/hw/sdp.h
 create mode 100644 drivers/common/cnxk/hw/sso.h
 create mode 100644 drivers/common/cnxk/hw/ssow.h
 create mode 100644 drivers/common/cnxk/hw/tim.h
 create mode 100644 drivers/common/cnxk/meson.build
 create mode 100644 drivers/common/cnxk/roc_api.h
 create mode 100644 drivers/common/cnxk/roc_bitfield.h
 create mode 100644 drivers/common/cnxk/roc_bits.h
 create mode 100644 drivers/common/cnxk/roc_dev.c
 create mode 100644 drivers/common/cnxk/roc_dev_priv.h
 create mode 100644 drivers/common/cnxk/roc_idev.c
 create mode 100644 drivers/common/cnxk/roc_idev.h
 create mode 100644 drivers/common/cnxk/roc_idev_priv.h
 create mode 100644 drivers/common/cnxk/roc_io.h
 create mode 100644 drivers/common/cnxk/roc_io_generic.h
 create mode 100644 drivers/common/cnxk/roc_irq.c
 create mode 100644 drivers/common/cnxk/roc_mbox.c
 create mode 100644 drivers/common/cnxk/roc_mbox.h
 create mode 100644 drivers/common/cnxk/roc_mbox_priv.h
 create mode 100644 drivers/common/cnxk/roc_model.c
 create mode 100644 drivers/common/cnxk/roc_model.h
 create mode 100644 drivers/common/cnxk/roc_nix.c
 create mode 100644 drivers/common/cnxk/roc_nix.h
 create mode 100644 drivers/common/cnxk/roc_nix_debug.c
 create mode 100644 drivers/common/cnxk/roc_nix_fc.c
 create mode 100644 drivers/common/cnxk/roc_nix_irq.c
 create mode 100644 drivers/common/cnxk/roc_nix_mac.c
 create mode 100644 drivers/common/cnxk/roc_nix_mcast.c
 create mode 100644 drivers/common/cnxk/roc_nix_npc.c
 create mode 100644 drivers/common/cnxk/roc_nix_ops.c
 create mode 100644 drivers/common/cnxk/roc_nix_priv.h
 create mode 100644 drivers/common/cnxk/roc_nix_ptp.c
 create mode 100644 drivers/common/cnxk/roc_nix_queue.c
 create mode 100644 drivers/common/cnxk/roc_nix_rss.c
 create mode 100644 drivers/common/cnxk/roc_nix_stats.c
 create mode 100644 drivers/common/cnxk/roc_nix_tm.c
 create mode 100644 drivers/common/cnxk/roc_nix_tm_ops.c
 create mode 100644 drivers/common/cnxk/roc_nix_tm_utils.c
 create mode 100644 drivers/common/cnxk/roc_nix_vlan.c
 create mode 100644 drivers/common/cnxk/roc_nix_xstats.h
 create mode 100644 drivers/common/cnxk/roc_npa.c
 create mode 100644 drivers/common/cnxk/roc_npa.h
 create mode 100644 drivers/common/cnxk/roc_npa_debug.c
 create mode 100644 drivers/common/cnxk/roc_npa_irq.c
 create mode 100644 drivers/common/cnxk/roc_npa_priv.h
 create mode 100644 drivers/common/cnxk/roc_npc.c
 create mode 100644 drivers/common/cnxk/roc_npc.h
 create mode 100644 drivers/common/cnxk/roc_npc_mcam.c
 create mode 100644 drivers/common/cnxk/roc_npc_parse.c
 create mode 100644 drivers/common/cnxk/roc_npc_priv.h
 create mode 100644 drivers/common/cnxk/roc_npc_utils.c
 create mode 100644 drivers/common/cnxk/roc_platform.c
 create mode 100644 drivers/common/cnxk/roc_platform.h
 create mode 100644 drivers/common/cnxk/roc_priv.h
 create mode 100644 drivers/common/cnxk/roc_sso.c
 create mode 100644 drivers/common/cnxk/roc_sso.h
 create mode 100644 drivers/common/cnxk/roc_sso_debug.c
 create mode 100644 drivers/common/cnxk/roc_sso_irq.c
 create mode 100644 drivers/common/cnxk/roc_sso_priv.h
 create mode 100644 drivers/common/cnxk/roc_tim.c
 create mode 100644 drivers/common/cnxk/roc_tim.h
 create mode 100644 drivers/common/cnxk/roc_tim_irq.c
 create mode 100644 drivers/common/cnxk/roc_tim_priv.h
 create mode 100644 drivers/common/cnxk/roc_util_priv.h
 create mode 100644 drivers/common/cnxk/roc_utils.c
 create mode 100644 drivers/common/cnxk/roc_utils.h
 create mode 100644 drivers/common/cnxk/version.map

--
2.8.4