ethernet: atheros: Add nss-gmac driver
Subsystems (3)
PATCH 1/1 ethernet: atheros: Add nss-gmac driver
This driver adds support for the internal GMACs on IPQ806x SoCs. It supports the device-tree and will register up to 4 ethernet interfaces.
--- drivers/net/ethernet/atheros/Kconfig | 10 + drivers/net/ethernet/atheros/Makefile | 1 + drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt | 14 + drivers/net/ethernet/atheros/nss-gmac/Makefile | 19 + .../atheros/nss-gmac/exports/nss_gmac_api_if.h | 126 ++ .../atheros/nss-gmac/include/msm_nss_gmac.h | 338 ++++ .../atheros/nss-gmac/include/msm_nss_macsec.h | 73 + .../atheros/nss-gmac/include/nss_gmac_clocks.h | 100 + .../atheros/nss-gmac/include/nss_gmac_dev.h | 2136 ++++++++++++++++++++ .../nss-gmac/include/nss_gmac_network_interface.h | 63 + .../net/ethernet/atheros/nss-gmac/nss_gmac_ctrl.c | 1210 +++++++++++ .../net/ethernet/atheros/nss-gmac/nss_gmac_dev.c | 1963 ++++++++++++++++++ .../ethernet/atheros/nss-gmac/nss_gmac_ethtool.c | 526 +++++ .../net/ethernet/atheros/nss-gmac/nss_gmac_init.c | 1131 +++++++++++ .../ethernet/atheros/nss-gmac/nss_gmac_mdiobus.c | 187 ++ .../atheros/nss-gmac/nss_gmac_tx_rx_offload.c | 1175 +++++++++++ 16 files changed, 9072 insertions(+) create mode 100644 drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt create mode 100644 drivers/net/ethernet/atheros/nss-gmac/Makefile create mode 100644 drivers/net/ethernet/atheros/nss-gmac/exports/nss_gmac_api_if.h create mode 100644 drivers/net/ethernet/atheros/nss-gmac/include/msm_nss_gmac.h create mode 100644 drivers/net/ethernet/atheros/nss-gmac/include/msm_nss_macsec.h create mode 100644 drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_clocks.h create mode 100644 drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_dev.h create mode 100644 drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_network_interface.h create mode 100644 drivers/net/ethernet/atheros/nss-gmac/nss_gmac_ctrl.c create mode 100644 drivers/net/ethernet/atheros/nss-gmac/nss_gmac_dev.c create mode 100644 drivers/net/ethernet/atheros/nss-gmac/nss_gmac_ethtool.c create mode 100644 drivers/net/ethernet/atheros/nss-gmac/nss_gmac_init.c create mode 100644 drivers/net/ethernet/atheros/nss-gmac/nss_gmac_mdiobus.c create mode 100644 drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c
drivers/net/ethernet/atheros/Kconfig +10 -0
@@ -80,4 +80,14 @@ config ALX To compile this driver as a module, choose M here. The module will be called alx. +config QCA_NSS_GMAC + tristate "Qualcomm/Atheros IPQ806x GMAC Ethernet support (EXPERIMENTAL)" + select NET_CORE + select MII + ---help--- + This driver supports the Qualcomm/Atheros GMAC ports in IPQ806x + chipset. Presents an ethernet interface to user space. + + The module will be called qca-nss-gmac. + endif # NET_VENDOR_ATHEROS
drivers/net/ethernet/atheros/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_ATL2) += atlx/ obj-$(CONFIG_ATL1E) += atl1e/ obj-$(CONFIG_ATL1C) += atl1c/ obj-$(CONFIG_ALX) += alx/ +obj-$(CONFIG_QCA_NSS_GMAC) += nss-gmac/
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +14 -0
@@ -0,0 +1,14 @@ +Linux Driver for 3504 DWC Ether MAC 10/100/1000 Universal +Linux Driver for 3507 DWC Ether MAC 10/100 Universal + +IMPORTANT: Synopsys Ethernet MAC Linux Software Drivers and documentation (hereinafter, "Software") are unsupported proprietary works of Synopsys, Inc. unless otherwise expressly agreed to in writing between Synopsys and you. + +The Software uses certain Linux kernel functionality and may therefore be subject to the GNU Public License which is available at: +http://www.gnu.org/licenses/gpl.html + +The Software IS NOT an item of Licensed Software or Licensed Product under any End User Software License Agreement or Agreement for Licensed Product with Synopsys or any supplement thereto. Synopsys permits you to use and redistribute this Software in source and binary forms, with or without modification, provided that redistributions of source code must retain this notice. Synopsys does not permit you to view, use, disclose, copy or distribute this file or any information contained herein except pursuant to this license grant from Synopsys, or to the extent it applies, the GNU Public License. If you do not agree with this notice, including the disclaimer below, then you are not authorized by Synopsys to use the Software. + +THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +
drivers/net/ethernet/atheros/nss-gmac/Makefile new file +19 -0
@@ -0,0 +1,19 @@ +################################################### +# Makefile for the NSS GMAC driver +################################################### + +obj ?= . + +obj-m += qca-nss-gmac.o + +qca-nss-gmac-objs += nss_gmac_dev.o \ + nss_gmac_ctrl.o \ + nss_gmac_init.o \ + nss_gmac_ethtool.o \ + nss_gmac_tx_rx_offload.o \ + nss_gmac_mdiobus.o + +GMAC_INCLUDE = -I$(obj)/include -I$(obj)/exports + +ccflags-y += $(GMAC_INCLUDE) +
drivers/net/ethernet/atheros/nss-gmac/exports/nss_gmac_api_if.h new file +126 -0
126 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/include/msm_nss_gmac.h new file +338 -0
338 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/include/msm_nss_macsec.h new file +73 -0
73 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_clocks.h new file +100 -0
100 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_dev.h new file +2136 -0
2,136 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_network_interface.h new file +63 -0
63 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_ctrl.c new file +1210 -0
113 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_dev.c new file +1963 -0
1,963 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_ethtool.c new file +526 -0
526 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_init.c new file +1131 -0
1,131 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_mdiobus.c new file +187 -0
187 lines not on this page · raw message
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c new file +1175 -0
1,175 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Part of the diff is not shown here. View the raw message.
A message that is not in the archive (sent off-list or not yet received): 1420754626-30121-1-git-send-email-wstephen-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Quoted 3 lines · Stephen Wang
This driver adds support for the internal GMACs on IPQ806x SoCs. It supports the device-tree and will register up to 4 ethernet interfaces.
Trivial:
You might try running the code through checkpatch.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Stephen Wang <[email protected]> :
Quoted 6 lines
This driver adds support for the internal GMACs on IPQ806x SoCs. It supports the device-tree and will register up to 4 ethernet interfaces.
Signed-off-by Stephen Wang <[email protected]>---
[...]
drivers/net/ethernet/atheros/nss-gmac/exports/nss_gmac_api_if.h line 60
Quoted 13 lines
drivers/net/ethernet/atheros/nss-gmac/exports/nss_gmac_api_if.h new file +13
-0+/* +* NSS GMAC data plane ops, default would be slowpath and can be override by +* nss-drv +*/ +struct nss_gmac_data_plane_ops { +int (*open)(void *ctx,uint32_t tx_desc_ring,uint32_t rx_desc_ring, +uint32_t mode); +int (*close)(void *ctx); +int (*link_state)(void *ctx,uint32_t link_state); +int (*mac_addr)(void *ctx,uint8_t *addr); +int (*change_mtu)(void *ctx,uint32_t mtu); +int (*xmit)(void *ctx,struct sk_buff *os_buf); +};
Weak types.
[...]
Quoted 28 lines
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c new file +28
-0+/* +* nss_gmac_register_offload() +* +* @param[netdev] netdev instance that is going to register +* @param[dp_ops] dataplan ops for chaning mac addr/mtu/link status +* @param[ctx] passing the ctx of this nss_phy_if to gmac +* +* @return Return SUCCESS or FAILURE +*/ +int nss_gmac_override_data_plane (struct net_device *netdev, +struct nss_gmac_data_plane_ops *dp_ops, +void *ctx) +{ +struct nss_gmac_dev *gmacdev = (struct nss_gmac_dev *)netdev_priv (netdev); + +BUG_ON (!gmacdev); + +if (!dp_ops->open || !dp_ops->close || !dp_ops->link_state + || !dp_ops->mac_addr || !dp_ops->change_mtu || !dp_ops->xmit) { +netdev_dbg (netdev,"%s: All the op functions must be present, reject this registeration" , + __func__); +return NSS_GMAC_FAILURE ; + } + +/* +* If this gmac is up, close the netdev to force TX/RX stop +*/ +if (test_bit (__NSS_GMAC_UP, &gmacdev->flags))
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c line 1105
Quoted 10 lines
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c new file +10
-0+nss_gmac_linux_close (netdev); + +/* Recored the data_plane_ctx, data_plane_ops */ + gmacdev->data_plane_ctx = ctx; + gmacdev->data_plane_ops = dp_ops; + gmacdev->first_linkup_done =0 ; + +return NSS_GMAC_SUCCESS ; +} +EXPORT_SYMBOL (nss_gmac_override_data_plane);
Why is this hook needed ?
Signature · 5 lines
Ueimor -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Stephen Wang
This driver adds support for the internal GMACs on IPQ806x SoCs. It supports the device-tree and will register up to 4 ethernet interfaces.
Signed-off-by Stephen Wang <[email protected]>--- drivers/net/ethernet/atheros/Kconfig | 10 + drivers/net/ethernet/atheros/Makefile | 1 + drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt | 14 + drivers/net/ethernet/atheros/nss-gmac/Makefile | 19 + .../atheros/nss-gmac/exports/nss_gmac_api_if.h | 126 ++ .../atheros/nss-gmac/include/msm_nss_gmac.h | 338 ++++ .../atheros/nss-gmac/include/msm_nss_macsec.h | 73 + .../atheros/nss-gmac/include/nss_gmac_clocks.h | 100 +
Quoted 8 lines
.../atheros/nss-gmac/include/nss_gmac_dev.h | 2136 ++++++++++++++++++++ .../nss-gmac/include/nss_gmac_network_interface.h | 63 + .../net/ethernet/atheros/nss-gmac/nss_gmac_ctrl.c | 1210 +++++++++++ .../net/ethernet/atheros/nss-gmac/nss_gmac_dev.c | 1963 ++++++++++++++++++ .../ethernet/atheros/nss-gmac/nss_gmac_ethtool.c | 526 +++++ .../net/ethernet/atheros/nss-gmac/nss_gmac_init.c | 1131 +++++++++++ .../ethernet/atheros/nss-gmac/nss_gmac_mdiobus.c | 187 ++ .../atheros/nss-gmac/nss_gmac_tx_rx_offload.c | 1175 +++++++++++
Device tree bindings _must_ be documented, yet this standalone patch adds nothing to Documentation/devicetree/bindings per the diffstat above. So trivial NAK until there's a patch documenting that.
See Documentation/devicetree/bindings/submitting-patches.txt
Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · On Thu, 8 Jan 2015 14:03:46 -0800 Stephen Wang…
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c new file +10
-0+static int32_t nss_gmac_setup_tx_desc_queue (struct nss_gmac_dev *gmacdev, +struct device *dev, +uint32_t no_of_desc, +uint32_t desc_mode) +{ +int32_t i; +struct dma_desc *first_desc =NULL ; +dma_addr_t dma_addr; + + gmacdev->tx_desc_count =0 ;
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c line 92
Quoted 10 lines
drivers/net/ethernet/atheros/nss-gmac/nss_gmac_tx_rx_offload.c new file +10
-0+ +BUG_ON (desc_mode !=RINGMODE ); +BUG_ON ((no_of_desc & (no_of_desc -1 )) !=0 ); + +netdev_dbg (gmacdev->netdev,"Total size of memory required for Tx Descriptors in Ring Mode = 0x%08x" + , (uint32_t ) ((sizeof (struct dma_desc ) * no_of_desc))); + + first_desc =dma_alloc_coherent (dev,sizeof (struct dma_desc ) * no_of_desc + , &dma_addr,GFP_KERNEL ); +if (first_desc ==NULL ) {
In a lot of places you first initialize a variable then assign it 5 lines later to it's initial value. Get rid of the first initialization. --
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · On Thursday 08 January 2015 14:03:46 Stephen Wang wrote:
This driver adds support for the internal GMACs on IPQ806x SoCs. It supports the device-tree and will register up to 4 ethernet interfaces.
Signed-off-by Stephen Wang <[email protected]>
Just a very brief review here. The driver is far too long to be reviewed in one piece, and hopefully is not needed at all if my suspicion is correct that we already have a driver for the hardware.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt line 7
Quoted 13 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +7
-0@@ -0,0 +1,14 @@ +Linux Driver for 3504 DWC Ether MAC 10/100/1000 Universal +Linux Driver for 3507 DWC Ether MAC 10/100 Universal + +IMPORTANT: Synopsys Ethernet MAC Linux Software Drivers and documentation (hereinafter, "Software") are unsupported proprietary works of Synopsys, Inc. unless otherwise expressly agreed to in writing between Synopsys and you. + +The Software uses certain Linux kernel functionality and may therefore be subject to the GNU Public License which is available at: +http://www.gnu.org/licenses/gpl.html
It sounds like this one is related to the dwmac driver in drivers/net/ethernet/stmicro/stmmac/. Please move the code into the same directory and reuse as much as you can.
If this is a completely unrelated part, it should probably go into drivers/net/ethernet/designware or drivers/net/ethernet/synopsys.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt line 12
Quoted 5 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +5
-0+#ifdef CONFIG_OF +#include <msm_nss_gmac.h> +#else +#include <mach/msm_nss_gmac.h> +#endif
Drop the non-CONFIG_OF part here and elsewhere, we don't support separate platform directories any more, and mach-qcom is already DT-only.
Quoted 7 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +7
-0+/********************************************************** + * GMAC registers Map + * For Pci based system address is BARx + gmac_register_base + * For any other system translation is done accordingly + **********************************************************/ +enum gmac_registers { + gmac_config = 0x0000, /* Mac config Register */
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 10 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +10
-0+ gmac_frame_filter = 0x0004, /* Mac frame filtering controls */ + gmac_hash_high = 0x0008, /* Multi-cast hash table high */ + gmac_hash_low = 0x000c, /* Multi-cast hash table low */ + gmac_gmii_addr = 0x0010, /* GMII address Register(ext. Phy) */ + gmac_gmii_data = 0x0014, /* GMII data Register(ext. Phy) */ + gmac_flow_control = 0x0018, /* Flow control Register */ + gmac_vlan = 0x001c, /* VLAN tag Register (IEEE 802.1Q) */ + gmac_version = 0x0020, /* GMAC Core Version Register */ + gmac_wakeup_addr = 0x0028, /* GMAC wake-up frame filter adrress + reg */
This looks a lot like dwmac1000 as well.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 10 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +10
-0+ if (of_property_read_u32(np, "qcom,id", &gmacdev->macid) + || of_property_read_u32(np, "qcom,emulation", &gmaccfg->emulation) + || of_property_read_u32(np, "qcom,phy_mii_type", &gmaccfg->phy_mii_type) + || of_property_read_u32(np, "qcom,phy_mdio_addr", &gmaccfg->phy_mdio_addr) + || of_property_read_u32(np, "qcom,rgmii_delay", &gmaccfg->rgmii_delay) + || of_property_read_u32(np, "qcom,poll_required", &gmaccfg->poll_required) + || of_property_read_u32(np, "qcom,forced_speed", &gmaccfg->forced_speed) + || of_property_read_u32(np, "qcom,forced_duplex", &gmaccfg->forced_duplex) + || of_property_read_u32(np, "qcom,irq", &netdev->irq) + || of_property_read_u32(np, "qcom,socver", &gmaccfg->socver)) {
This is not an acceptable way to pass data from DT, please use the standard properties.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 8 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +8
-0+ if (test_bit(__NSS_GMAC_LINKPOLL, &gmacdev->flags)) { +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) + gmacdev->phydev = phy_connect(netdev, (const char *)phy_id, + &nss_gmac_adjust_link, 0, phyif); +#else + gmacdev->phydev = phy_connect(netdev, (const char *)phy_id, + &nss_gmac_adjust_link, phyif); +#endif
Drop all LINUX_VERSION_CODE checks
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 5 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +5
-0+ if (IS_ERR_OR_NULL(gmacdev->phydev)) { + netdev_dbg(netdev, "PHY %s attach FAIL", phy_id); + ret = -EIO; + goto nss_gmac_phy_attach_fail; + }
Also any IS_ERR_OR_NULL checks, you are using the API incorrectly.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 8 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +8
-0+static struct of_device_id nss_gmac_dt_ids[] = { + { .compatible = "qcom,nss-gmac0" }, + { .compatible = "qcom,nss-gmac1" }, + { .compatible = "qcom,nss-gmac2" }, + { .compatible = "qcom,nss-gmac3" }, + {}, +}; +MODULE_DEVICE_TABLE(of, nss_gmac_dt_ids);
Are all four versions supported by this driver?
Each one of these needs its own devicetree binding that documents which hardware it is for and what the supported DT properties are.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 9 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +9
-0+static struct platform_driver nss_gmac_drv = { + .probe = nss_gmac_probe, + .remove = nss_gmac_remove, + .driver = { + .name = "nss-gmac", + .owner = THIS_MODULE, +#ifdef CONFIG_OF + .of_match_table = of_match_ptr(nss_gmac_dt_ids), +#endif
The redundancy here is redundant and unnecessary.
Quoted 4 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +4
-0+ +/** + * @brief IOCTL interface. + * This function is mainly for debugging purpose.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 10 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +10
-0+ * This provides hooks for Register read write, Retrieve descriptor status + * and Retreiving Device structure information. + * @param[in] pointer to net_device structure. + * @param[in] pointer to ifreq structure. + * @param[in] ioctl command. + * @return Returns 0 on success Error code on failure. + */ +static int32_t nss_gmac_linux_do_ioctl(struct net_device *netdev, + struct ifreq *ifr, int32_t cmd) +{
Remove the private ioctls.
Quoted 9 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +9
-0+/** + * @brief Stats Callback to receive statistics from NSS + * @param[in] pointer to gmac context + * @param[in] pointer to gmac statistics + * @return Returns void. + */ +static void nss_gmac_stats_receive(struct nss_gmac_dev *gmacdev, + struct nss_gmac_stats *gstat) +{
...
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 2 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +2
-0+} +EXPORT_SYMBOL(nss_gmac_receive);
Why multiple modules instead of linking everything together?
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 4 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +4
-0+ +/** + * NSS Driver interface APIs + */
What is an NSS driver?
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 13 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +13
-0+/* + * nss_gmac_open_work() + * Schedule delayed work to open the netdev again + */ +void nss_gmac_open_work(struct work_struct *work) +{ + struct nss_gmac_dev *gmacdev = container_of(to_delayed_work(work), + struct nss_gmac_dev, gmacwork); + + netdev_dbg(gmacdev->netdev, "Do the network up in delayed queue %s\n", + gmacdev->netdev->name); + nss_gmac_linux_open(gmacdev->netdev); +}
You seem to have an operating system abstraction layer in here. We know which OS we are running on, so please remove the abstraction.
Arnd
Hi Arnd, Francois
The nss-gmac driver is for the internal GMAC IP in the Qualcomm IPQ806x SoC. There are 2 ARM cores and 2 NSS cores inside the IPQ806x SoC. The main purpose of these NSS cores is to offload the networking stack from the ARM cores to achieve high performance at routing/ipsec..etc without exhausting the ARM core CPU cycles. There is another nss-drv driver for the NSS cores.
The nss-gmac driver is designed to work standalone or with the nss-drv driver so the switchable data plane overlay was implemented. When it worked standalone, the data plane is running on the ARM core as a standard networking driver. The nss-drv driver can take over the data plane and offload it to the NSS cores. The STMicro stmmac driver does not have this kind of overlay design so is not suitable for IPQ806x. This is why we don't based on the stmmac driver
Thanks,
Stephen
Quoted 178 lines
Quoted 16 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +4
-0@@ -0,0 +1,14 @@ +Linux Driver for 3504 DWC Ether MAC 10/100/1000 Universal +Linux Driver for 3507 DWC Ether MAC 10/100 Universal + +IMPORTANT: Synopsys Ethernet MAC Linux Software Drivers anddocumentation (hereinafter, "Software") are unsupported proprietary works of Synopsys, Inc. unless otherwise expressly agreed to in writing between Synopsys and you.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +2
-0+ +The Software uses certain Linux kernel functionality and may thereforeQuoted 2 lines
be subject to the GNU Public License which is available at:
+http://www.gnu.org/licenses/gpl.htmlIt sounds like this one is related to the dwmac driver in
drivers/net/ethernet/stmicro/stmmac/. Please move the code into the same directory and reuse as much as you can.If this is a completely unrelated part, it should probably go into
drivers/net/ethernet/designwareordrivers/net/ethernet/synopsys.drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 5 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +5
-0+#ifdef CONFIG_OF +#include <msm_nss_gmac.h> +#else +#include <mach/msm_nss_gmac.h> +#endifDrop the non-CONFIG_OF part here and elsewhere, we don't support separate platform directories any more, and mach-qcom is already DT-only.
Quoted 7 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +7
-0+/********************************************************** + * GMAC registers Map + * For Pci based system address is BARx + gmac_register_base + * For any other system translation is done accordingly + **********************************************************/ +enum gmac_registers { + gmac_config = 0x0000, /* Mac config Register */drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 10 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +10
-0+ gmac_frame_filter = 0x0004, /* Mac frame filtering controls */ + gmac_hash_high = 0x0008, /* Multi-cast hash table high */ + gmac_hash_low = 0x000c, /* Multi-cast hash table low */ + gmac_gmii_addr = 0x0010, /* GMII address Register(ext. Phy) */ + gmac_gmii_data = 0x0014, /* GMII data Register(ext. Phy) */ + gmac_flow_control = 0x0018, /* Flow control Register */ + gmac_vlan = 0x001c, /* VLAN tag Register (IEEE 802.1Q) */ + gmac_version = 0x0020, /* GMAC Core Version Register */ + gmac_wakeup_addr = 0x0028, /* GMAC wake-up frame filter adrress + reg */This looks a lot like dwmac1000 as well.
Quoted 14 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +3
-0+ if (of_property_read_u32(np, "qcom,id", &gmacdev->macid) + || of_property_read_u32(np, "qcom,emulation", &gmaccfg->emulation) + || of_property_read_u32(np, "qcom,phy_mii_type",
&gmaccfg->phy_mii_type)drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +1
-0+ || of_property_read_u32(np, "qcom,phy_mdio_addr",
&gmaccfg->phy_mdio_addr)drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +1
-0+ || of_property_read_u32(np, "qcom,rgmii_delay",
&gmaccfg->rgmii_delay)drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +1
-0+ || of_property_read_u32(np, "qcom,poll_required",
&gmaccfg->poll_required)drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +1
-0+ || of_property_read_u32(np, "qcom,forced_speed",
&gmaccfg->forced_speed)drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +1
-0+ || of_property_read_u32(np, "qcom,forced_duplex",
&gmaccfg->forced_duplex)drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 2 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +2
-0+ || of_property_read_u32(np, "qcom,irq", &netdev->irq) + || of_property_read_u32(np, "qcom,socver", &gmaccfg->socver)) {This is not an acceptable way to pass data from DT, please use the standard properties.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 8 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +8
-0+ if (test_bit(__NSS_GMAC_LINKPOLL, &gmacdev->flags)) { +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) + gmacdev->phydev = phy_connect(netdev, (const char *)phy_id, + &nss_gmac_adjust_link, 0, phyif); +#else + gmacdev->phydev = phy_connect(netdev, (const char *)phy_id, + &nss_gmac_adjust_link, phyif); +#endifDrop all
LINUX_VERSION_CODEchecksdrivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 5 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +5
-0+ if (IS_ERR_OR_NULL(gmacdev->phydev)) { + netdev_dbg(netdev, "PHY %s attach FAIL", phy_id); + ret = -EIO; + goto nss_gmac_phy_attach_fail; + }Also any
IS_ERR_OR_NULLchecks, you are using the API incorrectly.drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 8 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +8
-0+static struct of_device_id nss_gmac_dt_ids[] = { + { .compatible = "qcom,nss-gmac0" }, + { .compatible = "qcom,nss-gmac1" }, + { .compatible = "qcom,nss-gmac2" }, + { .compatible = "qcom,nss-gmac3" }, + {}, +}; +MODULE_DEVICE_TABLE(of, nss_gmac_dt_ids);Are all four versions supported by this driver?
Each one of these needs its own devicetree binding that documents which hardware it is for and what the supported DT properties are.
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 9 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +9
-0+static struct platform_driver nss_gmac_drv = { + .probe = nss_gmac_probe, + .remove = nss_gmac_remove, + .driver = { + .name = "nss-gmac", + .owner = THIS_MODULE, +#ifdef CONFIG_OF + .of_match_table = of_match_ptr(nss_gmac_dt_ids), +#endifThe redundancy here is redundant and unnecessary.
Quoted 12 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +5
-0+ +/** + * @brief IOCTL interface. + * This function is mainly for debugging purpose. + * This provides hooks for Register read write, Retrieve descriptorstatus
+ * and Retreiving Device structure information.
+ * @param[in] pointer tonet_devicestructure.
+ * @param[in] pointer to ifreq structure.
+ * @param[in] ioctl command.
+ * @return Returns 0 on success Error code on failure.
+ */drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 3 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +3
-0+static int32_t nss_gmac_linux_do_ioctl(struct net_device *netdev, + struct ifreq *ifr, int32_t cmd) +{Remove the private ioctls.
Quoted 9 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +9
-0+/** + * @brief Stats Callback to receive statistics from NSS + * @param[in] pointer to gmac context + * @param[in] pointer to gmac statistics + * @return Returns void. + */ +static void nss_gmac_stats_receive(struct nss_gmac_dev *gmacdev, + struct nss_gmac_stats *gstat) +{...
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 2 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +2
-0+} +EXPORT_SYMBOL(nss_gmac_receive);Why multiple modules instead of linking everything together?
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 4 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +4
-0+ +/** + * NSS Driver interface APIs + */What is an NSS driver?
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt
Quoted 13 lines
drivers/net/ethernet/atheros/nss-gmac/LICENSE.txt new file +13
-0+/* + * nss_gmac_open_work() + * Schedule delayed work to open the netdev again + */ +void nss_gmac_open_work(struct work_struct *work) +{ + struct nss_gmac_dev *gmacdev = container_of(to_delayed_work(work), + struct nss_gmac_dev, gmacwork); + + netdev_dbg(gmacdev->netdev, "Do the network up in delayed queue %s\n", + gmacdev->netdev->name); + nss_gmac_linux_open(gmacdev->netdev); +}You seem to have an operating system abstraction layer in here. We know which OS we are running on, so please remove the abstraction.
Quoted 2 lines
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · On Thursday 15 January 2015 08:12:51 [email protected] wrote:
The nss-gmac driver is for the internal GMAC IP in the Qualcomm IPQ806x SoC. There are 2 ARM cores and 2 NSS cores inside the IPQ806x SoC. The main purpose of these NSS cores is to offload the networking stack from the ARM cores to achieve high performance at routing/ipsec..etc without exhausting the ARM core CPU cycles. There is another nss-drv driver for the NSS cores.
I see.
Quoted 4 lines
The nss-gmac driver is designed to work standalone or with the nss-drv driver so the switchable data plane overlay was implemented. When it worked standalone, the data plane is running on the ARM core as a standard networking driver.
How do you decide which way it gets used on a particular system?
Quoted 4 lines
The nss-drv driver can take over the data plane and
offload it to the NSS cores. The STMicro stmmac driver does not have this kind of overlay design so is not suitable for IPQ806x. This is why we don't based on the stmmac driver
Which kind of offload is implemented specifically? 'data plane' sounds fairly generic and could mean anything, and the code isn't readable enough in its current form for me to find out.
Arnd
Quoted 11 lines · On Thursday 15 January 2015 08:12:51 [email protected]…
Quoted 7 lines
The nss-gmac driver is for the internal GMAC IP in the Qualcomm IPQ806x SoC. There are 2 ARM cores and 2 NSS cores inside the IPQ806x SoC. The main purpose of these NSS cores is to offload the networking stack from the ARM cores to achieve high performance at routing/ipsec..etc without exhausting the ARM core CPU cycles. There is another nss-drv driver for the NSS cores.
I see.
Quoted 8 lines
Quoted 5 lines
The nss-gmac driver is designed to work standalone or with the nss-drv driver so the switchable data plane overlay was implemented. When it worked standalone, the data plane is running on the ARM core as a standard
networking driver.How do you decide which way it gets used on a particular system?
By default the GMAC driver uses a native (Host ARM CPU) based data plane. If the configuration loads the offload nss-drv driver, the offload driver registers an overlay with the GMAC.
Quoted 9 lines
Quoted 5 lines
The nss-drv driver can take over the data plane and offload it to the NSS cores. The STMicro stmmac driver does not have this
kind of overlay design so is not suitable for IPQ806x. This is why we don't based on the stmmac driverWhich kind of offload is implemented specifically? 'data plane' sounds fairly generic and could mean anything, and the code isn't readable enough in its current form for me to find out.
The Network Subsystem (NSS core) provides a GMAC pass-through until it is given a rule to offload work. Once a rule is given, it is capable of
performing: bridging, IPv4 NAT/FWD, IPv6 NAT/FWD, IPSec, LAG, and other protocols.
Quoted 3 lines
Arnd
Hope this clarify your question!
Thanks,
Stephen
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · On Monday 19 January 2015 21:58:09 [email protected] wrote:
Quoted 8 lines · On Thursday 15 January 2015 08:12:51 [email protected] wrote:
Quoted 6 lines
The nss-gmac driver is designed to work standalone or with the nss-drv driver so the switchable data plane overlay was implemented. When it worked standalone, the data plane is running on the ARM core as a standard
networking driver.
Quoted 6 lines
Quoted 2 lines
How do you decide which way it gets used on a particular system?
By default the GMAC driver uses a native (Host ARM CPU) based data plane. If the configuration loads the offload nss-drv driver, the offload driver registers an overlay with the GMAC.
Right. For review purposes, I think it would be helpful to split this huge patch into several steps then:
- add a base driver
- add the overlay interface
- add the nss driver
Ideally more of them.
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
The nss-drv driver can take over the data plane and offload it to the NSS cores. The STMicro stmmac driver does not have this
kind of overlay design so is not suitable for IPQ806x. This is why we don't based on the stmmac driverWhich kind of offload is implemented specifically? 'data plane' sounds fairly generic and could mean anything, and the code isn't readable enough in its current form for me to find out.
Quoted 6 lines
The Network Subsystem (NSS core) provides a GMAC pass-through until it is given a rule to offload work. Once a rule is given, it is capable of
performing: bridging, IPv4 NAT/FWD, IPv6 NAT/FWD, IPSec, LAG, and other protocols.Hope this clarify your question!
Thanks for the description, this sounds very interesting indeed. I do have more questions though: how do you get the rules into the NSS driver? Does this get handled transparently by the openvswitch driver or did you have to add new user interfaces for it?
Arnd
Quoted 8 lines
Right. For review purposes, I think it would be helpful to split this huge patch into several steps then:
- add a base driver
- add the overlay interface
- add the nss driverIdeally more of them.
The nss-drv driver is open sourced but we are currently not planning to upstream to linux kernel yet because we are still actively adding new features
https://www.codeaurora.org/cgit/quic/qsdk/oss/lklm/nss-drv
Quoted 7 lines
Thanks for the description, this sounds very interesting indeed. I do have more questions though: how do you get the rules into the NSS driver? Does this get handled transparently by the openvswitch driver or did you have to add new user interfaces for it?
Arnd
No, we are not using openvswitch. We have a connection manager monitoring conntrack events and creates rules then send it through the interface built in nss-drv.
Thanks,
Stephen
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): f9cbb34c9228b2af7ed6c1c96a6aa61c.squirrel-mMfbam+mt9083fI46fginR2eb7JE58TQ@public.gmane.org
Quoted 20 lines · On Thursday 22 January 2015 00:20:59 [email protected]…
Quoted 8 lines
Right. For review purposes, I think it would be helpful to split this huge patch into several steps then:
- add a base driver
- add the overlay interface
- add the nss driverIdeally more of them.
The nss-drv driver is open sourced but we are currently not planning to upstream to linux kernel yet because we are still actively adding new features
https://www.codeaurora.org/cgit/quic/qsdk/oss/lklm/nss-drvQuoted 5 lines
Thanks for the description, this sounds very interesting indeed. I do have more questions though: how do you get the rules into the NSS driver? Does this get handled transparently by the openvswitch driver or did you have to add new user interfaces for it?
Quoted 4 lines
No, we are not using openvswitch. We have a connection manager monitoring conntrack events and creates rules then send it through the interface built in nss-drv.
I see. In this case, I think merging your new driver is not a good idea:
- We already have a driver (dwmac1000) for the ethernet hardware, which is known to work on a lot of hardware and has an established binding.
- The main difference in your new driver is the plug-in interface, but that has no upstream users
- The nss driver is not getting submitted, and has little chance of getting merged if you do, because it introduces a driver-specific API for something that should be hardware independent.
You can simplify your private nss code a lot if you remove the abstraction layer and only implement ethernet features you need in the same module, and then load either the upstream driver or your nss driver. Make sure they use a compatible binding so the device gets attached to just one of the two drivers. For the built-in case, you can use the 'unbind' interface from user space to remove the device from the dwmac1000 driver.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: Arnd Bergmann <[email protected]>
Date: Thu, 22 Jan 2015 11:18:50 +0100
Quoted 1 line
I see. In this case, I think merging your new driver is not a good idea:
+1
drivers/net/ethernet/atheros/nss-gmac/exports/nss_gmac_api_if.h line 69
Quoted 2 lines · On Thu, 8 Jan 2015 14:03:46 -0800 Stephen Wang <[email protected]> wrote:
drivers/net/ethernet/atheros/nss-gmac/exports/nss_gmac_api_if.h new file +2
-0+uint32_t rx_bytes;/**< Number of RX bytes */ +uint32_t rx_packets;/**< Number of RX packets */
32 bit packet stats are a problem with lots of traffic.
drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_dev.h line 241
Quoted 2 lines · On Thu, 8 Jan 2015 14:03:46 -0800 Stephen Wang <[email protected]> wrote:
drivers/net/ethernet/atheros/nss-gmac/include/nss_gmac_dev.h new file +2
-0+struct nss_gmac_data_plane_ops *data_plane_ops; +/* ops to send messages to nss-drv */
This should be a const pointer.