#include "cnxk_bphy_cgx.h"
#include "rte_pmd_bphy.h"
-static int
-cnxk_bphy_cgx_enq_msg(uint16_t dev_id, unsigned int queue, void *msg)
-{
- struct rte_rawdev_buf *bufs[1];
- struct rte_rawdev_buf buf;
- void *q;
- int ret;
-
- q = (void *)(size_t)queue;
- buf.buf_addr = msg;
- bufs[0] = &buf;
-
- ret = rte_rawdev_enqueue_buffers(dev_id, bufs, 1, q);
- if (ret < 0)
- return ret;
- if (ret != 1)
- return -EIO;
-
- return 0;
-}
-
-static int
-cnxk_bphy_cgx_deq_msg(uint16_t dev_id, unsigned int queue, void **msg)
-{
- struct rte_rawdev_buf *bufs[1];
- struct rte_rawdev_buf buf;
- void *q;
- int ret;
-
- q = (void *)(size_t)queue;
- bufs[0] = &buf;
-
- ret = rte_rawdev_dequeue_buffers(dev_id, bufs, 1, q);
- if (ret < 0)
- return ret;
- if (ret != 1)
- return -EIO;
-
- *msg = buf.buf_addr;
-
- return 0;
-}
-
static int
cnxk_bphy_cgx_link_cond(uint16_t dev_id, unsigned int queue, int cond)
{
+ struct cnxk_bphy_cgx_msg_link_info link_info;
int tries = 10, ret;
do {
- struct cnxk_bphy_cgx_msg_link_info *link_info = NULL;
- struct cnxk_bphy_cgx_msg msg;
-
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_GET_LINKINFO;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, queue, &msg);
- if (ret)
- return ret;
-
- ret = cnxk_bphy_cgx_deq_msg(dev_id, queue, (void **)&link_info);
+ ret = rte_pmd_bphy_cgx_get_link_info(dev_id, queue, &link_info);
if (ret)
return ret;
- if (link_info->link_up == cond) {
- rte_free(link_info);
+ if (link_info.link_up == cond)
break;
- }
- rte_free(link_info);
rte_delay_ms(500);
} while (--tries);
return -ETIMEDOUT;
}
-static int
-cnxk_bphy_cgx_get_supported_fec(uint16_t dev_id, unsigned int queue,
- enum cnxk_bphy_cgx_eth_link_fec *fec)
-{
- struct cnxk_bphy_cgx_msg msg = {
- .type = CNXK_BPHY_CGX_MSG_TYPE_GET_SUPPORTED_FEC,
- };
- int ret;
-
- ret = cnxk_bphy_cgx_enq_msg(dev_id, queue, &msg);
- if (ret)
- return ret;
-
- return cnxk_bphy_cgx_deq_msg(dev_id, queue, (void **)&fec);
-}
-
int
cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
{
return ret;
for (i = 0; i < queues; i++) {
- struct cnxk_bphy_cgx_msg_set_link_state link_state;
enum cnxk_bphy_cgx_eth_link_fec fec;
- struct cnxk_bphy_cgx_msg msg;
unsigned int descs;
ret = rte_rawdev_queue_conf_get(dev_id, i, &descs,
RTE_LOG(INFO, PMD, "Testing queue %d\n", i);
- /* stop rx/tx */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_STOP_RXTX;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_stop_rxtx(dev_id, i);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to stop rx/tx\n");
break;
}
- /* start rx/tx */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_START_RXTX;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_start_rxtx(dev_id, i);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to start rx/tx\n");
break;
}
- /* set link down */
- link_state.state = false;
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE;
- msg.data = &link_state;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, false);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to set link down\n");
break;
RTE_LOG(ERR, PMD,
"Timed out waiting for a link down\n");
- /* set link up */
- link_state.state = true;
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE;
- msg.data = &link_state;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, true);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to set link up\n");
break;
if (ret != 1)
RTE_LOG(ERR, PMD, "Timed out waiting for a link up\n");
- /* enable internal loopback */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_INTLBK_ENABLE;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_intlbk_enable(dev_id, i);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to enable internal lbk\n");
break;
}
- /* disable internal loopback */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_INTLBK_DISABLE;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_intlbk_disable(dev_id, i);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to disable internal lbk\n");
break;
}
- /* enable ptp */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_ENABLE;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_ptp_rx_enable(dev_id, i);
/* ptp not available on RPM */
if (ret < 0 && ret != -ENOTSUP) {
RTE_LOG(ERR, PMD, "Failed to enable ptp\n");
}
ret = 0;
- /* disable ptp */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_DISABLE;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_ptp_rx_disable(dev_id, i);
/* ptp not available on RPM */
if (ret < 0 && ret != -ENOTSUP) {
RTE_LOG(ERR, PMD, "Failed to disable ptp\n");
}
ret = 0;
- ret = cnxk_bphy_cgx_get_supported_fec(dev_id, i, &fec);
+ ret = rte_pmd_bphy_cgx_get_supported_fec(dev_id, i, &fec);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to get supported FEC\n");
break;
}
- /* set supported fec */
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_SET_FEC;
- msg.data = &fec;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_set_fec(dev_id, i, fec);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to set FEC to %d\n", fec);
break;
}
- /* disable fec */
fec = CNXK_BPHY_CGX_ETH_LINK_FEC_NONE;
- msg.type = CNXK_BPHY_CGX_MSG_TYPE_SET_FEC;
- msg.data = &fec;
- ret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);
+ ret = rte_pmd_bphy_cgx_set_fec(dev_id, i, fec);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to disable FEC\n");
break;