From d4547fd86c05cfa042bd46cfaf96a0f401eedb44 Mon Sep 17 00:00:00 2001 From: Mohit Dhingra Date: Mon, 18 Mar 2019 17:26:18 +0530 Subject: [PATCH] nvethernetrm: add tmake support - Split files into core and dma directories to add separate tmake files for creating separate RM and DMA channel libraries. ESQC-7634 Change-Id: Id9a2431bbee73a29b4a3565d8aa2bc0d8e7f0c78 Signed-off-by: Mohit Dhingra Reviewed-on: https://git-master.nvidia.com/r/2109978 Reviewed-by: Bitan Biswas GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- Makefile.umbrella.tmk | 34 ++++++ include/osi_common.h | 16 +-- include/osi_core.h | 197 +++++--------------------------- include/osi_dma.h | 123 ++++---------------- osi/core/Makefile.interface.tmk | 38 ++++++ osi/core/Makefile.tmk | 49 ++++++++ osi/{ => core}/eqos_core.c | 3 +- osi/{ => core}/eqos_core.h | 0 osi/core/libnvethernetrm.export | 45 ++++++++ osi/{ => core}/osi_common.c | 15 +++ osi/{ => core}/osi_core.c | 172 ++++++++++++++++++++++++++++ osi/dma/Makefile.interface.tmk | 39 +++++++ osi/dma/Makefile.tmk | 50 ++++++++ osi/{ => dma}/eqos_dma.c | 0 osi/{ => dma}/eqos_dma.h | 4 +- osi/dma/libnvethernetcl.export | 43 +++++++ osi/dma/osi_dma.c | 192 +++++++++++++++++++++++++++++++ osi/{ => dma}/osi_dma_txrx.c | 2 + osi/osi_dma.c | 81 ------------- 19 files changed, 734 insertions(+), 369 deletions(-) create mode 100644 Makefile.umbrella.tmk create mode 100644 osi/core/Makefile.interface.tmk create mode 100644 osi/core/Makefile.tmk rename osi/{ => core}/eqos_core.c (99%) rename osi/{ => core}/eqos_core.h (100%) create mode 100644 osi/core/libnvethernetrm.export rename osi/{ => core}/osi_common.c (94%) rename osi/{ => core}/osi_core.c (60%) create mode 100644 osi/dma/Makefile.interface.tmk create mode 100644 osi/dma/Makefile.tmk rename osi/{ => dma}/eqos_dma.c (100%) rename osi/{ => dma}/eqos_dma.h (98%) create mode 100644 osi/dma/libnvethernetcl.export create mode 100644 osi/dma/osi_dma.c rename osi/{ => dma}/osi_dma_txrx.c (99%) delete mode 100644 osi/osi_dma.c diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk new file mode 100644 index 0000000..5dc0f13 --- /dev/null +++ b/Makefile.umbrella.tmk @@ -0,0 +1,34 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# Repository umbrella makefile fragment for nvethernetrm +############################################################################### + +NV_REPOSITORY_COMPONENTS := \ + osi/core \ + osi/dma + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/include/osi_common.h b/include/osi_common.h index c14f2a2..ab7a86e 100644 --- a/include/osi_common.h +++ b/include/osi_common.h @@ -346,7 +346,7 @@ static inline void osi_writel(unsigned int val, void *addr) * * Return: 0 - for not Valid MAC, 1 - for Valid MAC */ -static int is_valid_mac_version(unsigned int mac_ver) +static inline int is_valid_mac_version(unsigned int mac_ver) { if ((mac_ver == OSI_EQOS_MAC_4_10) || (mac_ver == OSI_EQOS_MAC_5_00) || @@ -370,19 +370,7 @@ static int is_valid_mac_version(unsigned int mac_ver) * * Return: 0 - success, -1 - failure */ -static inline int osi_get_mac_version(void *addr, unsigned int *mac_ver) -{ - unsigned int macver; - int ret = 0; - - macver = osi_readl((unsigned char *)addr + MAC_VERSION) & MAC_VERSION_SNVER_MASK; - if (is_valid_mac_version(macver) == 0) { - return -1; - } - - *mac_ver = macver; - return ret; -} +int osi_get_mac_version(void *addr, unsigned int *mac_ver); void osi_get_hw_features(void *base, struct osi_hw_features *hw_feat); #endif /* OSI_COMMON_H */ diff --git a/include/osi_core.h b/include/osi_core.h index 9d828d2..3994801 100644 --- a/include/osi_core.h +++ b/include/osi_core.h @@ -141,17 +141,7 @@ struct osi_core_priv_data { * Return: 0 - success, -1 - failure */ -static inline int osi_poll_for_swr(struct osi_core_priv_data *osi_core) -{ - int ret = 0; - - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->poll_for_swr != OSI_NULL)) { - ret = osi_core->ops->poll_for_swr(osi_core->base); - } - - return ret; -} +int osi_poll_for_swr(struct osi_core_priv_data *osi_core); /** * osi_set_mdc_clk_rate - Derive MDC clock based on provided AXI_CBB clk. @@ -166,14 +156,8 @@ static inline int osi_poll_for_swr(struct osi_core_priv_data *osi_core) * * Return: None */ -static inline void osi_set_mdc_clk_rate(struct osi_core_priv_data *osi_core, - unsigned long csr_clk_rate) -{ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->set_mdc_clk_rate != OSI_NULL)) { - osi_core->ops->set_mdc_clk_rate(osi_core, csr_clk_rate); - } -} +void osi_set_mdc_clk_rate(struct osi_core_priv_data *osi_core, + unsigned long csr_clk_rate); /** * osi_hw_core_init - EQOS MAC, MTL and common DMA initialization. @@ -187,20 +171,9 @@ static inline void osi_set_mdc_clk_rate(struct osi_core_priv_data *osi_core, * * Return: 0 - success, -1 - failure */ -static inline int osi_hw_core_init(struct osi_core_priv_data *osi_core, - unsigned int tx_fifo_size, - unsigned int rx_fifo_size) -{ - int ret = 0; - - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->core_init != OSI_NULL)) { - ret = osi_core->ops->core_init(osi_core, tx_fifo_size, - rx_fifo_size); - } - - return ret; -} +int osi_hw_core_init(struct osi_core_priv_data *osi_core, + unsigned int tx_fifo_size, + unsigned int rx_fifo_size); /** * osi_start_mac - Start MAC Tx/Rx engine @@ -211,13 +184,7 @@ static inline int osi_hw_core_init(struct osi_core_priv_data *osi_core, * Protection: None * Return: None */ -static inline void osi_start_mac(struct osi_core_priv_data *osi_core) -{ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->start_mac != OSI_NULL)) { - osi_core->ops->start_mac(osi_core->base); - } -} +void osi_start_mac(struct osi_core_priv_data *osi_core); /** * osi_stop_mac - Stop MAC Tx/Rx engine @@ -228,13 +195,7 @@ static inline void osi_start_mac(struct osi_core_priv_data *osi_core) * Protection: None * Return: None */ -static inline void osi_stop_mac(struct osi_core_priv_data *osi_core) -{ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->stop_mac != OSI_NULL)) { - osi_core->ops->stop_mac(osi_core->base); - } -} +void osi_stop_mac(struct osi_core_priv_data *osi_core); /** * osi_common_isr - Common ISR. @@ -251,13 +212,7 @@ static inline void osi_stop_mac(struct osi_core_priv_data *osi_core) * * Return: 0 - success, -1 - failure */ -static inline void osi_common_isr(struct osi_core_priv_data *osi_core) -{ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->handle_common_intr != OSI_NULL)) { - osi_core->ops->handle_common_intr(osi_core); - } -} +void osi_common_isr(struct osi_core_priv_data *osi_core); /** * osi_set_mode - Set FD/HD mode. @@ -274,13 +229,7 @@ static inline void osi_common_isr(struct osi_core_priv_data *osi_core) * * Return: NONE */ -static inline void osi_set_mode(struct osi_core_priv_data *osi_core, int mode) -{ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->set_mode != OSI_NULL)) { - osi_core->ops->set_mode(osi_core->base, mode); - } -} +void osi_set_mode(struct osi_core_priv_data *osi_core, int mode); /** * osi_set_speed - Set operating speed. @@ -297,13 +246,7 @@ static inline void osi_set_mode(struct osi_core_priv_data *osi_core, int mode) * * Return: NONE */ -static inline void osi_set_speed(struct osi_core_priv_data *osi_core, int speed) -{ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->set_speed != OSI_NULL)) { - osi_core->ops->set_speed(osi_core->base, speed); - } -} +void osi_set_speed(struct osi_core_priv_data *osi_core, int speed); /** * osi_pad_calibrate - PAD calibration @@ -319,17 +262,7 @@ static inline void osi_set_speed(struct osi_core_priv_data *osi_core, int speed) * * Return: 0 - success, -1 - failure */ -static inline int osi_pad_calibrate(struct osi_core_priv_data *osi_core) -{ - int ret = 0; - - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->pad_calibrate != OSI_NULL)) { - ret = osi_core->ops->pad_calibrate(osi_core); - } - - return ret; -} +int osi_pad_calibrate(struct osi_core_priv_data *osi_core); /** * osi_flush_mtl_tx_queue - Flushing a MTL Tx Queue. @@ -345,18 +278,8 @@ static inline int osi_pad_calibrate(struct osi_core_priv_data *osi_core) * * Return: 0 - success, -1 - failure. */ -static inline int osi_flush_mtl_tx_queue(struct osi_core_priv_data *osi_core, - unsigned int qinx) -{ - int ret = 0; - - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->flush_mtl_tx_queue != OSI_NULL)) { - ret = osi_core->ops->flush_mtl_tx_queue(osi_core->base, qinx); - } - - return ret; -} +int osi_flush_mtl_tx_queue(struct osi_core_priv_data *osi_core, + unsigned int qinx); /** * osi_config_mac_loopback - Configure MAC loopback @@ -372,20 +295,8 @@ static inline int osi_flush_mtl_tx_queue(struct osi_core_priv_data *osi_core, * * Return: 0 - success, -1 - failure. */ -static inline int osi_config_mac_loopback(struct osi_core_priv_data *osi_core, - unsigned int lb_mode) -{ - int ret = -1; - - /* Configure MAC LoopBack */ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->config_mac_loopback != OSI_NULL)) { - ret = osi_core->ops->config_mac_loopback(osi_core->base, - lb_mode); - } - - return ret; -} +int osi_config_mac_loopback(struct osi_core_priv_data *osi_core, + unsigned int lb_mode); /** * osi_set_avb - Set CBS algo and parameters @@ -400,18 +311,8 @@ static inline int osi_config_mac_loopback(struct osi_core_priv_data *osi_core, * * Return: Success = 0; failure = -1; */ -static inline int osi_set_avb(struct osi_core_priv_data *osi_core, - struct osi_core_avb_algorithm *avb) -{ - int ret = -1; - - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->set_avb_algorithm != OSI_NULL)) { - ret = osi_core->ops->set_avb_algorithm(osi_core, avb); - } - - return ret; -} +int osi_set_avb(struct osi_core_priv_data *osi_core, + struct osi_core_avb_algorithm *avb); /** * osi_get_avb - Set CBS algo and parameters @@ -426,18 +327,8 @@ static inline int osi_set_avb(struct osi_core_priv_data *osi_core, * * Return: Success = 0; failure = -1; */ -static inline int osi_get_avb(struct osi_core_priv_data *osi_core, - struct osi_core_avb_algorithm *avb) -{ - int ret = -1; - - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->get_avb_algorithm != OSI_NULL)) { - ret = osi_core->ops->get_avb_algorithm(osi_core, avb); - } - - return ret; -} +int osi_get_avb(struct osi_core_priv_data *osi_core, + struct osi_core_avb_algorithm *avb); /** * osi_configure_txstatus - Configure Tx packet status reporting @@ -454,20 +345,8 @@ static inline int osi_get_avb(struct osi_core_priv_data *osi_core, * * Return: 0 - success, -1 - failure. */ -static inline int osi_configure_txstatus(struct osi_core_priv_data *osi_core, - unsigned int tx_status) -{ - int ret = -1; - - /* Configure Drop Transmit Status */ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->config_tx_status != OSI_NULL)) { - ret = osi_core->ops->config_tx_status(osi_core->base, - tx_status); - } - - return ret; -} +int osi_configure_txstatus(struct osi_core_priv_data *osi_core, + unsigned int tx_status); /** * osi_config_fw_err_pkts - Configure forwarding of error packets @@ -484,20 +363,8 @@ static inline int osi_configure_txstatus(struct osi_core_priv_data *osi_core, * * Return: 0 - success, -1 - failure. */ -static inline int osi_config_fw_err_pkts(struct osi_core_priv_data *osi_core, - unsigned int qinx, unsigned int fw_err) -{ - int ret = -1; - - /* Configure Forwarding of Error packets */ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->config_fw_err_pkts != OSI_NULL)) { - ret = osi_core->ops->config_fw_err_pkts(osi_core->base, - qinx, fw_err); - } - - return ret; -} +int osi_config_fw_err_pkts(struct osi_core_priv_data *osi_core, + unsigned int qinx, unsigned int fw_err); /** * osi_config_rx_crc_check - Configure CRC Checking for Received Packets @@ -515,20 +382,8 @@ static inline int osi_config_fw_err_pkts(struct osi_core_priv_data *osi_core, * * Return: 0 - success, -1 - failure. */ -static inline int osi_config_rx_crc_check(struct osi_core_priv_data *osi_core, - unsigned int crc_chk) -{ - int ret = -1; - - /* Configure CRC Checking for Received Packets */ - if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->config_rx_crc_check != OSI_NULL)) { - ret = osi_core->ops->config_rx_crc_check(osi_core->base, - crc_chk); - } - - return ret; -} +int osi_config_rx_crc_check(struct osi_core_priv_data *osi_core, + unsigned int crc_chk); int osi_write_phy_reg(struct osi_core_priv_data *osi_core, unsigned int phyaddr, unsigned int phyreg, unsigned short phydata); diff --git a/include/osi_dma.h b/include/osi_dma.h index a06df16..ef98906 100644 --- a/include/osi_dma.h +++ b/include/osi_dma.h @@ -259,14 +259,8 @@ struct osi_dma_priv_data { * * Return: None. */ -static inline void osi_disable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->disable_chan_tx_intr != OSI_NULL)) { - osi_dma->ops->disable_chan_tx_intr(osi_dma->base, chan); - } -} +void osi_disable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_enable_chan_tx_intr - Enable DMA Tx channel interrupts. @@ -281,14 +275,8 @@ static inline void osi_disable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, * * Return: None. */ -static inline void osi_enable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->enable_chan_tx_intr != OSI_NULL)) { - osi_dma->ops->enable_chan_tx_intr(osi_dma->base, chan); - } -} +void osi_enable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_disable_chan_rx_intr - Disable DMA Rx channel interrupts. @@ -303,14 +291,8 @@ static inline void osi_enable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, * * Return: None. */ -static inline void osi_disable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->disable_chan_rx_intr != OSI_NULL)) { - osi_dma->ops->disable_chan_rx_intr(osi_dma->base, chan); - } -} +void osi_disable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_enable_chan_rx_intr - Enable DMA Rx channel interrupts. @@ -325,14 +307,8 @@ static inline void osi_disable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, * * Return: None. */ -static inline void osi_enable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->enable_chan_rx_intr != OSI_NULL)) { - osi_dma->ops->enable_chan_rx_intr(osi_dma->base, chan); - } -} +void osi_enable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_clear_tx_intr - Handles Tx interrupt source. @@ -347,14 +323,8 @@ static inline void osi_enable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, * * Return: None. */ -static inline void osi_clear_tx_intr(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->clear_tx_intr != OSI_NULL)) { - osi_dma->ops->clear_tx_intr(osi_dma->base, chan); - } -} +void osi_clear_tx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_clear_rx_intr - Handles Rx interrupt source. @@ -369,14 +339,8 @@ static inline void osi_clear_tx_intr(struct osi_dma_priv_data *osi_dma, * * Return: None. */ -static inline void osi_clear_rx_intr(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->clear_rx_intr != OSI_NULL)) { - osi_dma->ops->clear_rx_intr(osi_dma->base, chan); - } -} +void osi_clear_rx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_start_dma - Start DMA @@ -388,14 +352,8 @@ static inline void osi_clear_rx_intr(struct osi_dma_priv_data *osi_dma, * Protection: None * Return: None */ -static inline void osi_start_dma(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->start_dma != OSI_NULL)) { - osi_dma->ops->start_dma(osi_dma->base, chan); - } -} +void osi_start_dma(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_stop_dma - Stop DMA @@ -407,14 +365,8 @@ static inline void osi_start_dma(struct osi_dma_priv_data *osi_dma, * Protection: None * Return: None */ -static inline void osi_stop_dma(struct osi_dma_priv_data *osi_dma, - unsigned int chan) -{ - if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && - (osi_dma->ops->stop_dma != OSI_NULL)) { - osi_dma->ops->stop_dma(osi_dma->base, chan); - } -} +void osi_stop_dma(struct osi_dma_priv_data *osi_dma, + unsigned int chan); /** * osi_get_refill_rx_desc_cnt - Rx descriptors count that needs to refill. @@ -429,10 +381,7 @@ static inline void osi_stop_dma(struct osi_dma_priv_data *osi_dma, * * Return: Number of available free descriptors. */ -static inline unsigned int osi_get_refill_rx_desc_cnt(struct osi_rx_ring *rx_ring) -{ - return (rx_ring->cur_rx_idx - rx_ring->refill_idx) & (RX_DESC_CNT - 1U); -} +unsigned int osi_get_refill_rx_desc_cnt(struct osi_rx_ring *rx_ring); /** * osi_rx_dma_desc_init - DMA Rx descriptor init @@ -447,14 +396,8 @@ static inline unsigned int osi_get_refill_rx_desc_cnt(struct osi_rx_ring *rx_rin * * Return: None. */ -static inline void osi_rx_dma_desc_init(struct osi_rx_swcx *rx_swcx, - struct osi_rx_desc *rx_desc) -{ - rx_desc->rdes0 = (unsigned int)L32(rx_swcx->buf_phy_addr); - rx_desc->rdes1 = (unsigned int)H32(rx_swcx->buf_phy_addr); - rx_desc->rdes2 = 0; - rx_desc->rdes3 = (RDES3_OWN | RDES3_IOC | RDES3_B1V); -} +void osi_rx_dma_desc_init(struct osi_rx_swcx *rx_swcx, + struct osi_rx_desc *rx_desc); /** * osi_update_rx_tailptr - Updates DMA Rx ring tail pointer @@ -470,22 +413,9 @@ static inline void osi_rx_dma_desc_init(struct osi_rx_swcx *rx_swcx, * * Return: None. */ -static inline void osi_update_rx_tailptr(struct osi_dma_priv_data *osi_dma, - struct osi_rx_ring *rx_ring, - unsigned int chan) -{ - unsigned long tailptr = 0; - unsigned int refill_idx = rx_ring->refill_idx; - - DECR_RX_DESC_INDEX(refill_idx, 1U); - tailptr = rx_ring->rx_desc_phy_addr + - (refill_idx * sizeof(struct osi_rx_desc)); - - if (osi_dma != OSI_NULL && osi_dma->ops != OSI_NULL && - osi_dma->ops->update_rx_tailptr != OSI_NULL) { - osi_dma->ops->update_rx_tailptr(osi_dma->base, chan, tailptr); - } -} +void osi_update_rx_tailptr(struct osi_dma_priv_data *osi_dma, + struct osi_rx_ring *rx_ring, + unsigned int chan); /** * osi_set_rx_buf_len - Updates rx buffer length. @@ -499,14 +429,7 @@ static inline void osi_update_rx_tailptr(struct osi_dma_priv_data *osi_dma, * * Return: None. */ - -static inline void osi_set_rx_buf_len(struct osi_dma_priv_data *osi_dma) -{ - if (osi_dma != OSI_NULL && osi_dma->ops != OSI_NULL && - osi_dma->ops->set_rx_buf_len != OSI_NULL) { - osi_dma->ops->set_rx_buf_len(osi_dma); - } -} +void osi_set_rx_buf_len(struct osi_dma_priv_data *osi_dma); void osi_hw_transmit(struct osi_dma_priv_data *osi, unsigned int chan); int osi_process_tx_completions(struct osi_dma_priv_data *osi, diff --git a/osi/core/Makefile.interface.tmk b/osi/core/Makefile.interface.tmk new file mode 100644 index 0000000..4637979 --- /dev/null +++ b/osi/core/Makefile.interface.tmk @@ -0,0 +1,38 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# libnvethernetrm interface makefile fragment +# +############################################################################### + +ifdef NV_INTERFACE_FLAG_SHARED_LIBRARY_SECTION +NV_INTERFACE_NAME := nvethernetrm +NV_INTERFACE_EXPORTS := lib$(NV_INTERFACE_NAME) +NV_INTERFACE_PUBLIC_INCLUDES := \ + ./include +endif + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/osi/core/Makefile.tmk b/osi/core/Makefile.tmk new file mode 100644 index 0000000..516063b --- /dev/null +++ b/osi/core/Makefile.tmk @@ -0,0 +1,49 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +ifdef NV_COMPONENT_FLAG_SHARED_LIBRARY_SECTION +include $(NV_BUILD_START_COMPONENT) + +NV_COMPONENT_NAME := nvethernetrm +NV_COMPONENT_OWN_INTERFACE_DIR := . +NV_COMPONENT_SOURCES := \ + eqos_core.c \ + osi_common.c \ + osi_core.c + +NV_COMPONENT_NEEDED_INTERFACE_DIRS := \ + $(NV_SOURCE)/qnx/src/libs/nvethernet/osi_dependencies + +NV_COMPONENT_INCLUDES := \ + $(NV_SOURCE)/nvethernetrm/include \ + $(NV_SOURCE)/core/include + +include $(NV_BUILD_SHARED_LIBRARY) +endif + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/osi/eqos_core.c b/osi/core/eqos_core.c similarity index 99% rename from osi/eqos_core.c rename to osi/core/eqos_core.c index 911274e..2db301f 100644 --- a/osi/eqos_core.c +++ b/osi/core/eqos_core.c @@ -1174,7 +1174,8 @@ static int eqos_get_avb_algorithm(struct osi_core_priv_data *osi_core, EQOS_MTL_TXQ_ETS_CR_AVALG_SHIFT; /* Get Send slope credit */ - value = osi_readl(osi_core->base + EQOS_MTL_TXQ_ETS_SSCR(qinx)); + value = osi_readl((unsigned char *)osi_core->base + + EQOS_MTL_TXQ_ETS_SSCR(qinx)); avb->send_slope = value & EQOS_MTL_TXQ_ETS_SSCR_SSC_MASK; /* Get Idle slope credit*/ diff --git a/osi/eqos_core.h b/osi/core/eqos_core.h similarity index 100% rename from osi/eqos_core.h rename to osi/core/eqos_core.h diff --git a/osi/core/libnvethernetrm.export b/osi/core/libnvethernetrm.export new file mode 100644 index 0000000..fbdc186 --- /dev/null +++ b/osi/core/libnvethernetrm.export @@ -0,0 +1,45 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# libnvethernetrm interface export +# +############################################################################### +osi_init_core_ops +osi_write_phy_reg +osi_read_phy_reg +osi_poll_for_swr +osi_set_mdc_clk_rate +osi_hw_core_init +osi_start_mac +osi_stop_mac +osi_common_isr +osi_set_mode +osi_set_speed +osi_pad_calibrate +osi_flush_mtl_tx_queue +osi_config_mac_loopback +osi_set_avb +osi_get_avb +osi_configure_txstatus +osi_config_rx_crc_check +osi_get_mac_version +osi_get_hw_features diff --git a/osi/osi_common.c b/osi/core/osi_common.c similarity index 94% rename from osi/osi_common.c rename to osi/core/osi_common.c index ffa5209..ba8da0a 100644 --- a/osi/osi_common.c +++ b/osi/core/osi_common.c @@ -118,3 +118,18 @@ void osi_get_hw_features(void *base, struct osi_hw_features *hw_feat) hw_feat->aux_snap_num = ((mac_hfr2 >> 28U) & EQOS_MAC_HFR2_AUXSNAPNUM_MASK); } + +int osi_get_mac_version(void *addr, unsigned int *mac_ver) +{ + unsigned int macver; + int ret = 0; + + macver = osi_readl((unsigned char *)addr + MAC_VERSION) & + MAC_VERSION_SNVER_MASK; + if (is_valid_mac_version(macver) == 0) { + return -1; + } + + *mac_ver = macver; + return ret; +} diff --git a/osi/osi_core.c b/osi/core/osi_core.c similarity index 60% rename from osi/osi_core.c rename to osi/core/osi_core.c index 6e290af..79a975a 100644 --- a/osi/osi_core.c +++ b/osi/core/osi_core.c @@ -225,3 +225,175 @@ void osi_init_core_ops(struct osi_core_priv_data *osi_core) osi_core->ops = eqos_get_hw_core_ops(); } } + +int osi_poll_for_swr(struct osi_core_priv_data *osi_core) +{ + int ret = 0; + + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->poll_for_swr != OSI_NULL)) { + ret = osi_core->ops->poll_for_swr(osi_core->base); + } + + return ret; +} + +void osi_set_mdc_clk_rate(struct osi_core_priv_data *osi_core, + unsigned long csr_clk_rate) +{ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->set_mdc_clk_rate != OSI_NULL)) { + osi_core->ops->set_mdc_clk_rate(osi_core, csr_clk_rate); + } +} + +int osi_hw_core_init(struct osi_core_priv_data *osi_core, + unsigned int tx_fifo_size, + unsigned int rx_fifo_size) +{ + int ret = 0; + + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->core_init != OSI_NULL)) { + ret = osi_core->ops->core_init(osi_core, tx_fifo_size, + rx_fifo_size); + } + + return ret; +} + +void osi_start_mac(struct osi_core_priv_data *osi_core) +{ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->start_mac != OSI_NULL)) { + osi_core->ops->start_mac(osi_core->base); + } +} + +void osi_stop_mac(struct osi_core_priv_data *osi_core) +{ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->stop_mac != OSI_NULL)) { + osi_core->ops->stop_mac(osi_core->base); + } +} + +void osi_common_isr(struct osi_core_priv_data *osi_core) +{ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->handle_common_intr != OSI_NULL)) { + osi_core->ops->handle_common_intr(osi_core); + } +} + +void osi_set_mode(struct osi_core_priv_data *osi_core, int mode) +{ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->set_mode != OSI_NULL)) { + osi_core->ops->set_mode(osi_core->base, mode); + } +} + +void osi_set_speed(struct osi_core_priv_data *osi_core, int speed) +{ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->set_speed != OSI_NULL)) { + osi_core->ops->set_speed(osi_core->base, speed); + } +} + +int osi_pad_calibrate(struct osi_core_priv_data *osi_core) +{ + int ret = 0; + + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->pad_calibrate != OSI_NULL)) { + ret = osi_core->ops->pad_calibrate(osi_core); + } + + return ret; +} + +int osi_flush_mtl_tx_queue(struct osi_core_priv_data *osi_core, + unsigned int qinx) +{ + int ret = 0; + + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->flush_mtl_tx_queue != OSI_NULL)) { + ret = osi_core->ops->flush_mtl_tx_queue(osi_core->base, qinx); + } + + return ret; +} + +int osi_config_mac_loopback(struct osi_core_priv_data *osi_core, + unsigned int lb_mode) +{ + int ret = -1; + + /* Configure MAC LoopBack */ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->config_mac_loopback != OSI_NULL)) { + ret = osi_core->ops->config_mac_loopback(osi_core->base, + lb_mode); + } + + return ret; +} + +int osi_set_avb(struct osi_core_priv_data *osi_core, + struct osi_core_avb_algorithm *avb) +{ + int ret = -1; + + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->set_avb_algorithm != OSI_NULL)) { + ret = osi_core->ops->set_avb_algorithm(osi_core, avb); + } + + return ret; +} + +int osi_get_avb(struct osi_core_priv_data *osi_core, + struct osi_core_avb_algorithm *avb) +{ + int ret = -1; + + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->get_avb_algorithm != OSI_NULL)) { + ret = osi_core->ops->get_avb_algorithm(osi_core, avb); + } + + return ret; +} + +int osi_configure_txstatus(struct osi_core_priv_data *osi_core, + unsigned int tx_status) +{ + int ret = -1; + + /* Configure Drop Transmit Status */ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->config_tx_status != OSI_NULL)) { + ret = osi_core->ops->config_tx_status(osi_core->base, + tx_status); + } + + return ret; +} + +int osi_config_rx_crc_check(struct osi_core_priv_data *osi_core, + unsigned int crc_chk) +{ + int ret = -1; + + /* Configure CRC Checking for Received Packets */ + if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && + (osi_core->ops->config_rx_crc_check != OSI_NULL)) { + ret = osi_core->ops->config_rx_crc_check(osi_core->base, + crc_chk); + } + + return ret; +} diff --git a/osi/dma/Makefile.interface.tmk b/osi/dma/Makefile.interface.tmk new file mode 100644 index 0000000..c12901e --- /dev/null +++ b/osi/dma/Makefile.interface.tmk @@ -0,0 +1,39 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# libnvethernetcl interface makefile fragment +# +############################################################################### + +ifdef NV_INTERFACE_FLAG_SHARED_LIBRARY_SECTION +NV_INTERFACE_NAME := nvethernetcl +NV_INTERFACE_EXPORTS := lib$(NV_INTERFACE_NAME) +NV_INTERFACE_PUBLIC_INCLUDES := \ + ./include +endif + + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/osi/dma/Makefile.tmk b/osi/dma/Makefile.tmk new file mode 100644 index 0000000..e61be7b --- /dev/null +++ b/osi/dma/Makefile.tmk @@ -0,0 +1,50 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +ifdef NV_COMPONENT_FLAG_SHARED_LIBRARY_SECTION +include $(NV_BUILD_START_COMPONENT) + +NV_COMPONENT_NAME := nvethernetcl +NV_COMPONENT_OWN_INTERFACE_DIR := . +NV_COMPONENT_SOURCES := \ + eqos_dma.c \ + osi_dma.c \ + osi_dma_txrx.c + +NV_COMPONENT_NEEDED_INTERFACE_DIRS := \ + $(NV_SOURCE)/qnx/src/libs/nvethernet/osi_dependencies + +NV_COMPONENT_INCLUDES := \ + $(NV_SOURCE)/nvethernetrm/include \ + $(NV_SOURCE)/core/include + +include $(NV_BUILD_SHARED_LIBRARY) +endif + + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/osi/eqos_dma.c b/osi/dma/eqos_dma.c similarity index 100% rename from osi/eqos_dma.c rename to osi/dma/eqos_dma.c diff --git a/osi/eqos_dma.h b/osi/dma/eqos_dma.h similarity index 98% rename from osi/eqos_dma.h rename to osi/dma/eqos_dma.h index 39bd892..322acc2 100644 --- a/osi/eqos_dma.h +++ b/osi/dma/eqos_dma.h @@ -20,8 +20,8 @@ * DEALINGS IN THE SOFTWARE. */ -#ifndef EQOS_H_ -#define EQOS_H_ +#ifndef EQOS_DMA_H_ +#define EQOS_DMA_H_ #define EQOS_AXI_BUS_WIDTH 0x10U diff --git a/osi/dma/libnvethernetcl.export b/osi/dma/libnvethernetcl.export new file mode 100644 index 0000000..d9bbb0c --- /dev/null +++ b/osi/dma/libnvethernetcl.export @@ -0,0 +1,43 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# libnvethernetcl interface export +# +############################################################################### +osi_disable_chan_tx_intr +osi_enable_chan_tx_intr +osi_disable_chan_rx_intr +osi_enable_chan_rx_intr +osi_clear_tx_intr +osi_clear_rx_intr +osi_start_dma +osi_stop_dma +osi_get_refill_rx_desc_cnt +osi_rx_dma_desc_init +osi_update_rx_tailptr +osi_set_rx_buf_len +osi_hw_transmit +osi_process_tx_completions +osi_process_rx_completions +osi_hw_dma_init +osi_hw_dma_deinit +osi_init_dma_ops diff --git a/osi/dma/osi_dma.c b/osi/dma/osi_dma.c new file mode 100644 index 0000000..f62de65 --- /dev/null +++ b/osi/dma/osi_dma.c @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +extern int dma_desc_init(struct osi_dma_priv_data *osi_dma); +extern struct osi_dma_chan_ops *eqos_get_dma_chan_ops(void); + +void osi_init_dma_ops(struct osi_dma_priv_data *osi_dma) +{ + if (osi_dma->mac == OSI_MAC_HW_EQOS) { + /* Get EQOS HW ops */ + osi_dma->ops = eqos_get_dma_chan_ops(); + } +} + +int osi_hw_dma_init(struct osi_dma_priv_data *osi_dma) +{ + unsigned int i, chan; + int ret; + + if (osi_dma->ops->init_dma_channel != OSI_NULL) { + osi_dma->ops->init_dma_channel(osi_dma); + } + + ret = dma_desc_init(osi_dma); + if (ret != 0) { + return ret; + } + + /* Enable channel interrupts at wrapper level and start DMA */ + for (i = 0; i < osi_dma->num_dma_chans; i++) { + chan = osi_dma->dma_chans[i]; + + osi_enable_chan_tx_intr(osi_dma, chan); + osi_enable_chan_rx_intr(osi_dma, chan); + osi_start_dma(osi_dma, chan); + } + + return 0; +} + +/** + * osi_hw_deinit - De-init the HW + * @osi: OSI private data structure. + * + * Algorithm: + * 1) Stop the DMA + * 2) free all allocated resources. + * + * Dependencies: None + * Protection: None + * Return: None + */ +void osi_hw_dma_deinit(struct osi_dma_priv_data *osi_dma) +{ + unsigned int i; + + for (i = 0; i < osi_dma->num_dma_chans; i++) { + osi_stop_dma(osi_dma, osi_dma->dma_chans[i]); + } +} + +void osi_disable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->disable_chan_tx_intr != OSI_NULL)) { + osi_dma->ops->disable_chan_tx_intr(osi_dma->base, chan); + } +} + +void osi_enable_chan_tx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->enable_chan_tx_intr != OSI_NULL)) { + osi_dma->ops->enable_chan_tx_intr(osi_dma->base, chan); + } +} + +void osi_disable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->disable_chan_rx_intr != OSI_NULL)) { + osi_dma->ops->disable_chan_rx_intr(osi_dma->base, chan); + } +} + +void osi_enable_chan_rx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->enable_chan_rx_intr != OSI_NULL)) { + osi_dma->ops->enable_chan_rx_intr(osi_dma->base, chan); + } +} + +void osi_clear_tx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->clear_tx_intr != OSI_NULL)) { + osi_dma->ops->clear_tx_intr(osi_dma->base, chan); + } +} + +void osi_clear_rx_intr(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->clear_rx_intr != OSI_NULL)) { + osi_dma->ops->clear_rx_intr(osi_dma->base, chan); + } +} + +void osi_start_dma(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->start_dma != OSI_NULL)) { + osi_dma->ops->start_dma(osi_dma->base, chan); + } +} + +void osi_stop_dma(struct osi_dma_priv_data *osi_dma, + unsigned int chan) +{ + if ((osi_dma != OSI_NULL) && (osi_dma->ops != OSI_NULL) && + (osi_dma->ops->stop_dma != OSI_NULL)) { + osi_dma->ops->stop_dma(osi_dma->base, chan); + } +} + +unsigned int osi_get_refill_rx_desc_cnt(struct osi_rx_ring *rx_ring) +{ + return (rx_ring->cur_rx_idx - rx_ring->refill_idx) & (RX_DESC_CNT - 1U); +} + +void osi_rx_dma_desc_init(struct osi_rx_swcx *rx_swcx, + struct osi_rx_desc *rx_desc) +{ + rx_desc->rdes0 = (unsigned int)L32(rx_swcx->buf_phy_addr); + rx_desc->rdes1 = (unsigned int)H32(rx_swcx->buf_phy_addr); + rx_desc->rdes2 = 0; + rx_desc->rdes3 = (RDES3_OWN | RDES3_IOC | RDES3_B1V); +} + +void osi_update_rx_tailptr(struct osi_dma_priv_data *osi_dma, + struct osi_rx_ring *rx_ring, + unsigned int chan) +{ + unsigned long tailptr = 0; + unsigned int refill_idx = rx_ring->refill_idx; + + DECR_RX_DESC_INDEX(refill_idx, 1U); + tailptr = rx_ring->rx_desc_phy_addr + + (refill_idx * sizeof(struct osi_rx_desc)); + + if (osi_dma != OSI_NULL && osi_dma->ops != OSI_NULL && + osi_dma->ops->update_rx_tailptr != OSI_NULL) { + osi_dma->ops->update_rx_tailptr(osi_dma->base, chan, tailptr); + } +} + +void osi_set_rx_buf_len(struct osi_dma_priv_data *osi_dma) +{ + if (osi_dma != OSI_NULL && osi_dma->ops != OSI_NULL && + osi_dma->ops->set_rx_buf_len != OSI_NULL) { + osi_dma->ops->set_rx_buf_len(osi_dma); + } +} diff --git a/osi/osi_dma_txrx.c b/osi/dma/osi_dma_txrx.c similarity index 99% rename from osi/osi_dma_txrx.c rename to osi/dma/osi_dma_txrx.c index 5220929..ec55c8d 100644 --- a/osi/osi_dma_txrx.c +++ b/osi/dma/osi_dma_txrx.c @@ -24,6 +24,8 @@ #include #include +int dma_desc_init(struct osi_dma_priv_data *osi_dma); + static inline void osi_memset(void *s, int c, unsigned long count) { char *xs = s; diff --git a/osi/osi_dma.c b/osi/osi_dma.c deleted file mode 100644 index 6ad8e39..0000000 --- a/osi/osi_dma.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include - -extern int dma_desc_init(struct osi_dma_priv_data *osi_dma); -extern struct osi_dma_chan_ops *eqos_get_dma_chan_ops(void); - -void osi_init_dma_ops(struct osi_dma_priv_data *osi_dma) -{ - if (osi_dma->mac == OSI_MAC_HW_EQOS) { - /* Get EQOS HW ops */ - osi_dma->ops = eqos_get_dma_chan_ops(); - } -} - -int osi_hw_dma_init(struct osi_dma_priv_data *osi_dma) -{ - unsigned int i, chan; - int ret; - - if (osi_dma->ops->init_dma_channel != OSI_NULL) { - osi_dma->ops->init_dma_channel(osi_dma); - } - - ret = dma_desc_init(osi_dma); - if (ret != 0) { - return ret; - } - - /* Enable channel interrupts at wrapper level and start DMA */ - for (i = 0; i < osi_dma->num_dma_chans; i++) { - chan = osi_dma->dma_chans[i]; - - osi_enable_chan_tx_intr(osi_dma, chan); - osi_enable_chan_rx_intr(osi_dma, chan); - osi_start_dma(osi_dma, chan); - } - - return 0; -} - -/** - * osi_hw_deinit - De-init the HW - * @osi: OSI private data structure. - * - * Algorithm: - * 1) Stop the DMA - * 2) free all allocated resources. - * - * Dependencies: None - * Protection: None - * Return: None - */ -void osi_hw_dma_deinit(struct osi_dma_priv_data *osi_dma) -{ - unsigned int i; - - for (i = 0; i < osi_dma->num_dma_chans; i++) { - osi_stop_dma(osi_dma, osi_dma->dma_chans[i]); - } -}