Skip to content

Commit

Permalink
net/xsc: add ethdev link and MTU ops
Browse files Browse the repository at this point in the history
Implement xsc ethdev link and MTU ops.

Signed-off-by: Renyong Wan <[email protected]>
  • Loading branch information
Renyong Wan authored and shemminger committed Jan 28, 2025
1 parent 4edac52 commit 7e08e8f
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/guides/nics/features/xsc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
; Refer to default.ini for the full list of available PMD features.
;
[Features]
MTU update = Y
RSS hash = Y
RSS key update = Y
RSS reta update = Y
Expand Down
33 changes: 33 additions & 0 deletions drivers/net/xsc/xsc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,39 @@ xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
data_out, out_len);
}

int
xsc_dev_set_link_up(struct xsc_dev *xdev)
{
if (xdev->dev_ops->set_link_up == NULL)
return -ENOTSUP;

return xdev->dev_ops->set_link_up(xdev);
}

int
xsc_dev_set_link_down(struct xsc_dev *xdev)
{
if (xdev->dev_ops->set_link_down == NULL)
return -ENOTSUP;

return xdev->dev_ops->set_link_down(xdev);
}

int
xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete)
{
if (xdev->dev_ops->link_update == NULL)
return -ENOTSUP;

return xdev->dev_ops->link_update(xdev, funcid_type, wait_to_complete);
}

int
xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu)
{
return xdev->dev_ops->set_mtu(xdev, mtu);
}

int
xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)
{
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/xsc/xsc_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ struct xsc_dev_ops {
int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
int in_len, void *data_out, int out_len);
void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
int xsc_dev_set_link_up(struct xsc_dev *xdev);
int xsc_dev_set_link_down(struct xsc_dev *xde);
int xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete);
int xsc_dev_destroy_qp(struct xsc_dev *xdev, void *qp);
int xsc_dev_destroy_cq(struct xsc_dev *xdev, void *cq);
int xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode);
Expand All @@ -175,6 +178,7 @@ int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_et
int xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len);
bool xsc_dev_is_vf(struct xsc_dev *xdev);
int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id);
int xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu);
int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac);

#endif /* _XSC_DEV_H_ */
60 changes: 60 additions & 0 deletions drivers/net/xsc/xsc_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,41 @@ xsc_ethdev_close(struct rte_eth_dev *dev)
return 0;
}

static int
xsc_ethdev_set_link_up(struct rte_eth_dev *dev)
{
struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
struct xsc_dev *xdev = priv->xdev;

return xsc_dev_set_link_up(xdev);
}

static int
xsc_ethdev_set_link_down(struct rte_eth_dev *dev)
{
struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
struct xsc_dev *xdev = priv->xdev;

return xsc_dev_set_link_down(xdev);
}

static int
xsc_ethdev_link_update(struct rte_eth_dev *dev,
int wait_to_complete)
{
struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
struct xsc_dev *xdev = priv->xdev;
int ret = 0;

ret = xsc_dev_link_update(xdev, priv->funcid_type, wait_to_complete);
if (ret == 0) {
dev->data->dev_link = xdev->pf_dev_link;
dev->data->dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
RTE_ETH_LINK_SPEED_FIXED);
}
return ret;
}

static uint64_t
xsc_get_rx_queue_offloads(struct rte_eth_dev *dev)
{
Expand Down Expand Up @@ -503,6 +538,27 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
return 0;
}

static int
xsc_ethdev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
{
struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
int ret = 0;

if (priv->eth_type != RTE_ETH_REPRESENTOR_PF) {
priv->mtu = mtu;
return 0;
}

ret = xsc_dev_set_mtu(priv->xdev, mtu);
if (ret) {
PMD_DRV_LOG(ERR, "Mtu set to %u failure", mtu);
return -EAGAIN;
}

priv->mtu = mtu;
return 0;
}

static int
xsc_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
{
Expand Down Expand Up @@ -606,14 +662,18 @@ const struct eth_dev_ops xsc_eth_dev_ops = {
.dev_configure = xsc_ethdev_configure,
.dev_start = xsc_ethdev_start,
.dev_stop = xsc_ethdev_stop,
.dev_set_link_up = xsc_ethdev_set_link_up,
.dev_set_link_down = xsc_ethdev_set_link_down,
.dev_close = xsc_ethdev_close,
.link_update = xsc_ethdev_link_update,
.stats_get = xsc_ethdev_stats_get,
.stats_reset = xsc_ethdev_stats_reset,
.dev_infos_get = xsc_ethdev_infos_get,
.rx_queue_setup = xsc_ethdev_rx_queue_setup,
.tx_queue_setup = xsc_ethdev_tx_queue_setup,
.rx_queue_release = xsc_ethdev_rxq_release,
.tx_queue_release = xsc_ethdev_txq_release,
.mtu_set = xsc_ethdev_set_mtu,
.rss_hash_update = xsc_ethdev_rss_hash_update,
.rss_hash_conf_get = xsc_ethdev_rss_hash_conf_get,
};
Expand Down

0 comments on commit 7e08e8f

Please sign in to comment.