X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Focteontx2%2Fotx2_ptp.c;h=abb21305879226a2510c1f9484448d624f1f2eb6;hb=46c6714ffd4326cd9ea884a9812a459a444f464a;hp=160d7c9abad34d373b51171c739c064482226333;hpb=7ab3aec60239f35be45069b354b4502ea28a3120;p=dpdk.git diff --git a/drivers/net/octeontx2/otx2_ptp.c b/drivers/net/octeontx2/otx2_ptp.c index 160d7c9aba..abb2130587 100644 --- a/drivers/net/octeontx2/otx2_ptp.c +++ b/drivers/net/octeontx2/otx2_ptp.c @@ -2,12 +2,44 @@ * Copyright(C) 2019 Marvell International Ltd. */ -#include +#include #include "otx2_ethdev.h" #define PTP_FREQ_ADJUST (1 << 9) +/* Function to enable ptp config for VFs */ +void +otx2_nix_ptp_enable_vf(struct rte_eth_dev *eth_dev) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + + if (otx2_nix_recalc_mtu(eth_dev)) + otx2_err("Failed to set MTU size for ptp"); + + dev->scalar_ena = true; + dev->rx_offload_flags |= NIX_RX_OFFLOAD_TSTAMP_F; + + /* Setting up the function pointers as per new offload flags */ + otx2_eth_set_rx_function(eth_dev); + otx2_eth_set_tx_function(eth_dev); +} + +static uint16_t +nix_eth_ptp_vf_burst(void *queue, struct rte_mbuf **mbufs, uint16_t pkts) +{ + struct otx2_eth_rxq *rxq = queue; + struct rte_eth_dev *eth_dev; + + RTE_SET_USED(mbufs); + RTE_SET_USED(pkts); + + eth_dev = rxq->eth_dev; + otx2_nix_ptp_enable_vf(eth_dev); + + return 0; +} + static int nix_read_raw_clock(struct otx2_eth_dev *dev, uint64_t *clock, uint64_t *tsc, uint8_t is_pmu) @@ -104,7 +136,7 @@ nix_ptp_config(struct rte_eth_dev *eth_dev, int en) struct otx2_mbox *mbox = dev->mbox; uint8_t rc = -EINVAL; - if (otx2_dev_is_vf(dev)) + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) return rc; if (en) { @@ -153,6 +185,17 @@ otx2_eth_dev_ptp_info_update(struct otx2_dev *dev, bool ptp_en) otx2_nix_rxq_mbuf_setup(otx2_dev, eth_dev->data->port_id); } + if (otx2_dev_is_vf(otx2_dev) && !(otx2_dev_is_sdp(otx2_dev)) && + !(otx2_dev_is_lbk(otx2_dev))) { + /* In case of VF, setting of MTU cant be done directly in this + * function as this is running as part of MBOX request(PF->VF) + * and MTU setting also requires MBOX message to be + * sent(VF->PF) + */ + eth_dev->rx_pkt_burst = nix_eth_ptp_vf_burst; + rte_mb(); + } + return 0; } @@ -162,20 +205,27 @@ otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev) struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); int i, rc = 0; - if (otx2_ethdev_is_ptp_en(dev)) { - otx2_info("PTP mode is already enabled "); + /* If we are VF/SDP/LBK, ptp cannot not be enabled */ + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) { + otx2_info("PTP cannot be enabled in case of VF/SDP/LBK"); return -EINVAL; } - /* If we are VF, no further action can be taken */ - if (otx2_dev_is_vf(dev)) + if (otx2_ethdev_is_ptp_en(dev)) { + otx2_info("PTP mode is already enabled"); return -EINVAL; + } if (!(dev->rx_offload_flags & NIX_RX_OFFLOAD_PTYPE_F)) { otx2_err("Ptype offload is disabled, it should be enabled"); return -EINVAL; } + if (dev->npc_flow.switch_header_type == OTX2_PRIV_FLAGS_HIGIG) { + otx2_err("Both PTP and switch header enabled"); + return -EINVAL; + } + /* Allocating a iova address for tx tstamp */ const struct rte_memzone *ts; ts = rte_eth_dma_zone_reserve(eth_dev, "otx2_ts", @@ -189,10 +239,18 @@ otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev) dev->tstamp.tx_tstamp_iova = ts->iova; dev->tstamp.tx_tstamp = ts->addr; + rc = rte_mbuf_dyn_rx_timestamp_register( + &dev->tstamp.tstamp_dynfield_offset, + &dev->tstamp.rx_tstamp_dynflag); + if (rc != 0) { + otx2_err("Failed to register Rx timestamp field/flag"); + return -rte_errno; + } + /* System time should be already on by default */ nix_start_timecounters(eth_dev); - dev->rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; + dev->rx_offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP; dev->rx_offload_flags |= NIX_RX_OFFLOAD_TSTAMP_F; dev->tx_offload_flags |= NIX_TX_OFFLOAD_TSTAMP_F; @@ -207,6 +265,11 @@ otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev) otx2_eth_set_rx_function(eth_dev); otx2_eth_set_tx_function(eth_dev); } + + rc = otx2_nix_recalc_mtu(eth_dev); + if (rc) + otx2_err("Failed to set MTU size for ptp"); + return rc; } @@ -221,11 +284,10 @@ otx2_nix_timesync_disable(struct rte_eth_dev *eth_dev) return -EINVAL; } - /* If we are VF, nothing else can be done */ - if (otx2_dev_is_vf(dev)) + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) return -EINVAL; - dev->rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; + dev->rx_offloads &= ~RTE_ETH_RX_OFFLOAD_TIMESTAMP; dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_TSTAMP_F; dev->tx_offload_flags &= ~NIX_TX_OFFLOAD_TSTAMP_F; @@ -240,6 +302,11 @@ otx2_nix_timesync_disable(struct rte_eth_dev *eth_dev) otx2_eth_set_rx_function(eth_dev); otx2_eth_set_tx_function(eth_dev); } + + rc = otx2_nix_recalc_mtu(eth_dev); + if (rc) + otx2_err("Failed to set MTU size for ptp"); + return rc; }