From 7f172a52f59ed8ea3f27711834b0d8180a5e7da2 Mon Sep 17 00:00:00 2001 From: Mohan Thadikamalla Date: Fri, 13 Mar 2020 17:28:16 +0530 Subject: [PATCH] nvethernet: Add PTP RX queue support - Define new "nvidia,ptp_rx_queue" DT node entry - Read "nvidia,ptp_rx_queue" DT node value into osi_core->ptp_config.ptp_rx_queue. On no DT entry case set this value to "osi_core->mtl_queues[0]" - Validate "osi_core->ptp_config.ptp_rx_queue" value with "osi_core->mtl_queues" array values. If no match found give error and set this value to "osi_core->mtl_queues[0]" - Add new private IOCTL command to call OSI RX route API. Bug 200596985 Change-Id: I2c05d4c6f3f4207d9efd6b6777d29fe2409de1a3 Signed-off-by: Mohan Thadikamalla Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2312295 Reviewed-by: automaticguardword Reviewed-by: Narayan Reddy Reviewed-by: Rakesh Goyal --- .../ethernet/nvidia/nvethernet/ether_linux.c | 20 +++++++ .../net/ethernet/nvidia/nvethernet/ioctl.c | 52 +++++++++++++++---- .../net/ethernet/nvidia/nvethernet/ioctl.h | 1 + 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 164bdecf..7fa66219 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -3851,6 +3851,26 @@ static int ether_parse_dt(struct ether_priv_data *pdata) goto exit; } } + /* Read PTP Rx queue index */ + ret = of_property_read_u32(np, "nvidia,ptp-rx-queue", + &osi_core->ptp_config.ptp_rx_queue); + if (ret != 0) { + dev_warn(dev, "Setting default PTP RX queue\n"); + osi_core->ptp_config.ptp_rx_queue = osi_core->mtl_queues[0]; + } else { + /* Validate PTP Rx queue index */ + for (i = 0; i < osi_core->num_mtl_queues; i++) { + if (osi_core->mtl_queues[i] == + osi_core->ptp_config.ptp_rx_queue) + break; + } + if (i == osi_core->num_mtl_queues) { + dev_err(dev, "Invalid PTP RX queue in DT:%d\n", + osi_core->ptp_config.ptp_rx_queue); + osi_core->ptp_config.ptp_rx_queue = + osi_core->mtl_queues[0]; + } + } ret = of_property_read_u32_array(np, "nvidia,dma-chans", osi_dma->dma_chans, diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.c b/drivers/net/ethernet/nvidia/nvethernet/ioctl.c index 1c3a6927..057b6db4 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.c @@ -114,7 +114,7 @@ static bool ether_is_bc_addr(unsigned char *bc_addr) * * @note Ethernet interface need to be up. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "nagative value" on Failure */ static int ether_set_avb_algo(struct net_device *ndev, @@ -166,7 +166,7 @@ static int ether_set_avb_algo(struct net_device *ndev, * @note Ethernet interface need to be up. Caller should check for return * value before using return value. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_get_avb_algo(struct net_device *ndev, @@ -220,7 +220,7 @@ static int ether_get_avb_algo(struct net_device *ndev, * * @note Interface should be running (enforced by caller). * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_config_arp_offload(struct ether_priv_data *pdata, @@ -270,7 +270,7 @@ static int ether_config_arp_offload(struct ether_priv_data *pdata, * * @note MAC and PHY need to be initialized. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure * */ @@ -300,7 +300,7 @@ static int ether_config_l3_l4_filtering(struct net_device *dev, * * @note MAC and PHY need to be initialized. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_config_ip4_filters(struct net_device *dev, @@ -356,7 +356,7 @@ static int ether_config_ip4_filters(struct net_device *dev, * * @note MAC and PHY need to be initialized. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_config_ip6_filters(struct net_device *dev, @@ -414,7 +414,7 @@ static int ether_config_ip6_filters(struct net_device *dev, * * @note MAC and PHY need to be initialized. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_config_tcp_udp_filters(struct net_device *dev, @@ -470,7 +470,7 @@ static int ether_config_tcp_udp_filters(struct net_device *dev, * * @note MAC and PHY need to be initialized. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_config_vlan_filter(struct net_device *dev, @@ -524,7 +524,7 @@ static int ether_config_vlan_filter(struct net_device *dev, * * @note MAC and PHY need to be initialized. * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ static int ether_config_l2_da_filter(struct net_device *dev, @@ -686,6 +686,35 @@ static int ether_config_loopback_mode(struct net_device *ndev, return ret; } +/** + * @brief This function is invoked by ioctl when user issues an ioctl command + * to change PTP RX Packets routing + * + * Algorithm: + * 1) OSI call to configure PTP RX queue in HW. + * + * @param[in] ndev: pointer to net device structure. + * @param[in] flags: flag to indicate PTP RX queue index. + * + * @note MAC and PHY need to be initialized. + * + * @retval 0 on Success + * @retval "negative value" on Failure + */ +static int ether_config_ptp_rxq(struct net_device *ndev, + unsigned int flags) +{ + struct ether_priv_data *pdata = netdev_priv(ndev); + struct osi_core_priv_data *osi_core = pdata->osi_core; + struct osi_rxq_route rxq_route; + + /* Fill PTP RX queue route values and call osi_rxq_route */ + rxq_route.route_type = OSI_RXQ_ROUTE_PTP; + rxq_route.enable = OSI_ENABLE; + rxq_route.idx = flags; + return osi_rxq_route(osi_core, &rxq_route); +} + /** * @brief ether_priv_ioctl - Handle private IOCTLs * @@ -699,7 +728,7 @@ static int ether_config_loopback_mode(struct net_device *ndev, * * @note Interface should be running (enforced by caller). * - * @retval 0 on Sucess + * @retval 0 on Success * @retval "negative value" on Failure */ int ether_handle_priv_ioctl(struct net_device *ndev, @@ -769,6 +798,9 @@ int ether_handle_priv_ioctl(struct net_device *ndev, case ETHER_CONFIG_ARP_OFFLOAD: ret = ether_config_arp_offload(pdata, &ifdata); break; + case ETHER_PTP_RXQUEUE: + ret = ether_config_ptp_rxq(ndev, ifdata.if_flags); + break; case EQOS_L3_L4_FILTER_CMD: /* flags should be 0x0 or 0x1, discard any other */ if (pdata->hw_feat.l3l4_filter_num > 0U && diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h index 4b761060..7028a333 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h @@ -55,6 +55,7 @@ #define ETHER_CONFIG_LOOPBACK_MODE 40 #define ETHER_GET_AVB_ALGORITHM 46 #define ETHER_SAVE_RESTORE 47 +#define ETHER_PTP_RXQUEUE 48 /** @} */ /**