mem: add dirty malloc element support
[dpdk.git] / drivers / raw / cnxk_bphy / cnxk_bphy_cgx.c
index 6375144..0b694e1 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <roc_api.h>
 
+#include "cnxk_bphy_cgx.h"
 #include "rte_pmd_bphy.h"
 
 struct cnxk_bphy_cgx_queue {
@@ -27,7 +28,7 @@ static void
 cnxk_bphy_cgx_format_name(char *name, unsigned int len,
                          struct rte_pci_device *pci_dev)
 {
-       snprintf(name, len, "BPHY_CGX:%x:%02x.%x", pci_dev->addr.bus,
+       snprintf(name, len, "BPHY_CGX:%02x:%02x.%x", pci_dev->addr.bus,
                 pci_dev->addr.devid, pci_dev->addr.function);
 }
 
@@ -61,6 +62,7 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, unsigned int queue,
        struct cnxk_bphy_cgx_msg_link_info *link_info;
        struct roc_bphy_cgx_link_info rlink_info;
        struct roc_bphy_cgx_link_mode rlink_mode;
+       enum roc_bphy_cgx_eth_link_fec *fec;
        unsigned int lmac = qp->lmac;
        void *rsp = NULL;
        int ret;
@@ -121,6 +123,18 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, unsigned int queue,
        case CNXK_BPHY_CGX_MSG_TYPE_STOP_RXTX:
                ret = roc_bphy_cgx_stop_rxtx(cgx->rcgx, lmac);
                break;
+       case CNXK_BPHY_CGX_MSG_TYPE_GET_SUPPORTED_FEC:
+               fec = rte_zmalloc(NULL, sizeof(*fec), 0);
+               if (!fec)
+                       return -ENOMEM;
+
+               ret = roc_bphy_cgx_fec_supported_get(cgx->rcgx, lmac, fec);
+               rsp = fec;
+               break;
+       case CNXK_BPHY_CGX_MSG_TYPE_SET_FEC:
+               fec = msg->data;
+               ret = roc_bphy_cgx_fec_set(cgx->rcgx, lmac, *fec);
+               break;
        default:
                return -EINVAL;
        }
@@ -157,6 +171,32 @@ cnxk_bphy_cgx_enqueue_bufs(struct rte_rawdev *dev,
        return 1;
 }
 
+static int
+cnxk_bphy_cgx_dequeue_bufs(struct rte_rawdev *dev,
+                          struct rte_rawdev_buf **buffers, unsigned int count,
+                          rte_rawdev_obj_t context)
+{
+       struct cnxk_bphy_cgx *cgx = dev->dev_private;
+       unsigned int queue = (size_t)context;
+       struct cnxk_bphy_cgx_queue *qp;
+
+       if (queue >= cgx->num_queues)
+               return -EINVAL;
+
+       if (count == 0)
+               return 0;
+
+       qp = &cgx->queues[queue];
+       if (qp->rsp) {
+               buffers[0]->buf_addr = qp->rsp;
+               qp->rsp = NULL;
+
+               return 1;
+       }
+
+       return 0;
+}
+
 static uint16_t
 cnxk_bphy_cgx_queue_count(struct rte_rawdev *dev)
 {
@@ -168,7 +208,9 @@ cnxk_bphy_cgx_queue_count(struct rte_rawdev *dev)
 static const struct rte_rawdev_ops cnxk_bphy_cgx_rawdev_ops = {
        .queue_def_conf = cnxk_bphy_cgx_queue_def_conf,
        .enqueue_bufs = cnxk_bphy_cgx_enqueue_bufs,
+       .dequeue_bufs = cnxk_bphy_cgx_dequeue_bufs,
        .queue_count = cnxk_bphy_cgx_queue_count,
+       .dev_selftest = cnxk_bphy_cgx_dev_selftest,
 };
 
 static void