Rename functions and their prototypes and move to common files.
Subsystems (3)
cover Rename functions and their prototypes and move to common files.
From: Nagaraju DeepakX <[email protected]>
Hi,
Moving the standard DMA interface for SGDMA and MSGDMA and renaming from tse_private to dma_private. Moving read-write function prototypes from altera_tse.h to altera_utils.h. Commonize DMA for upcoming altera Drivers.
Patch1: Removing unneeded assignments.
Patch2: Fixing indentation warnings.
Patch3: Moving read write Function prototypes.
Patch4: Sorting headers in alphabetical order.
Patch5: Renaming function prototypes.
Nagaraju DeepakX (5):
net: ethernet: altera: remove unneeded assignments
net: ethernet: altera: fix indentation warnings
net: ethernet: altera: move read write functions
net: ethernet: altera: sorting headers in alphabetical order
net: ethernet: altera: rename functions and their prototypes
drivers/net/ethernet/altera/Makefile | 5 +- drivers/net/ethernet/altera/altera_eth_dma.c | 58 ++++ drivers/net/ethernet/altera/altera_eth_dma.h | 121 +++++++++ drivers/net/ethernet/altera/altera_msgdma.c | 38 +-- drivers/net/ethernet/altera/altera_msgdma.h | 28 +- drivers/net/ethernet/altera/altera_sgdma.c | 138 +++++----- drivers/net/ethernet/altera/altera_sgdma.h | 30 +-- drivers/net/ethernet/altera/altera_tse.h | 71 +---- .../net/ethernet/altera/altera_tse_ethtool.c | 2 + drivers/net/ethernet/altera/altera_tse_main.c | 251 +++++++----------- drivers/net/ethernet/altera/altera_utils.c | 1 + drivers/net/ethernet/altera/altera_utils.h | 43 +++ 12 files changed, 447 insertions(+), 339 deletions(-) create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.c create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.h
--
2.26.2
PATCH 1/5 net: ethernet: altera: remove unneeded assignments
From: Nagaraju DeepakX <[email protected]>
Remove unneeded assignments in the code.
--- drivers/net/ethernet/altera/altera_sgdma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/altera/altera_sgdma.c +2 -4
@@ -63,8 +63,6 @@ int sgdma_initialize(struct altera_tse_private *priv)INIT_LIST_HEAD (&priv->txlisthd);INIT_LIST_HEAD (&priv->rxlisthd); - priv->rxdescphys = (dma_addr_t )0 ; - priv->txdescphys = (dma_addr_t )0 ; priv->rxdescphys = dma_map_single(priv->device, (void __force *)priv->rx_dma_desc,
@@ -237,8 +235,8 @@ u32 sgdma_rx_status(struct altera_tse_private *priv) desc = &base[0 ];if (sts &SGDMA_STSREG_EOP ) { -unsigned int pktlength =0 ; -unsigned int pktstatus =0 ; +unsigned int pktlength; +unsigned int pktstatus; dma_sync_single_for_cpu(priv->device, priv->rxdescphys, SGDMA_DESC_LEN,
--
2.26.2
Re: [PATCH 1/5] net: ethernet: altera: remove unneeded assignments
Quoted 6 lines · On Wed, Dec 13, 2023 at 03:11:08PM +0800, [email protected] wrote:
From: Nagaraju DeepakX <[email protected]>
Remove unneeded assignments in the code.
Signed-off-by Nagaraju DeepakX <[email protected]>Reviewed-by Andy Schevchenko <[email protected]>
PATCH 2/5 net: ethernet: altera: fix indentation warnings
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Fix indentation issues such as missing a blank line after declarations and alignment issues.
--- drivers/net/ethernet/altera/altera_sgdma.c | 22 +++++++++---------- drivers/net/ethernet/altera/altera_tse_main.c | 9 +++----- 2 files changed, 14 insertions(+), 17 deletions(-)
drivers/net/ethernet/altera/altera_sgdma.c +11 -11
@@ -20,7 +20,7 @@ static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, int wfixed);static int sgdma_async_write (struct altera_tse_private *priv, -struct sgdma_descrip __iomem *desc); +struct sgdma_descrip __iomem *desc);static int sgdma_async_read (struct altera_tse_private *priv);
@@ -63,7 +63,6 @@ int sgdma_initialize(struct altera_tse_private *priv)INIT_LIST_HEAD (&priv->txlisthd);INIT_LIST_HEAD (&priv->rxlisthd); - priv->rxdescphys =dma_map_single (priv->device, (void __force *)priv->rx_dma_desc, priv->rxdescmem,DMA_BIDIRECTIONAL );
@@ -192,9 +191,7 @@ int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)return 1 ; } - -/* tx_lock held to protect access to queued tx list -*/ +/* tx_lock held to protect access to queued tx list */ u32 sgdma_tx_completions (struct altera_tse_private *priv) {u32 ready =0 ;
@@ -237,10 +234,9 @@ u32 sgdma_rx_status(struct altera_tse_private *priv)if (sts &SGDMA_STSREG_EOP ) {unsigned int pktlength;unsigned int pktstatus; -dma_sync_single_for_cpu (priv->device, - priv->rxdescphys, -SGDMA_DESC_LEN , -DMA_FROM_DEVICE ); + +dma_sync_single_for_cpu (priv->device, priv->rxdescphys, +SGDMA_DESC_LEN ,DMA_FROM_DEVICE ); pktlength =csrrd16 (desc,sgdma_descroffs (bytes_xferred)); pktstatus =csrrd8 (desc,sgdma_descroffs (status));
@@ -286,7 +282,6 @@ u32 sgdma_rx_status(struct altera_tse_private *priv)return rxstatus; } -/* Private functions */ static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, struct sgdma_descrip __iomem *ndesc,
@@ -301,6 +296,7 @@ static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc,/* Clear the next descriptor as not owned by hardware */ u32 ctrl =csrrd8 (ndesc,sgdma_descroffs (control)); + ctrl &= ~SGDMA_CONTROL_HW_OWNED ;csrwr8 (ctrl, ndesc,sgdma_descroffs (control));
@@ -406,6 +402,7 @@ sgdma_txphysaddr(struct altera_tse_private *priv, {dma_addr_t paddr = priv->txdescmem_busaddr;uintptr_t offs = (uintptr_t )desc - (uintptr_t )priv->tx_dma_desc; +return (dma_addr_t)((uintptr_t )paddr + offs); }
@@ -415,6 +412,7 @@ sgdma_rxphysaddr(struct altera_tse_private *priv, {dma_addr_t paddr = priv->rxdescmem_busaddr;uintptr_t offs = (uintptr_t )desc - (uintptr_t )priv->rx_dma_desc; +return (dma_addr_t)((uintptr_t )paddr + offs); }
@@ -445,7 +443,6 @@ queue_tx(struct altera_tse_private *priv, struct tse_buffer *buffer)list_add_tail (&buffer->lh, &priv->txlisthd); } -/* adds a tse_buffer to the tail of a rx buffer list * assumes the caller is managing and holding a mutual exclusion * primitive to avoid simultaneous pushes/pops to the list.
@@ -465,6 +462,7 @@ static struct tse_buffer * dequeue_tx(struct altera_tse_private *priv) {struct tse_buffer *buffer =NULL ; + list_remove_head(&priv->txlisthd, buffer, struct tse_buffer, lh);return buffer; }
@@ -478,6 +476,7 @@ static struct tse_buffer * dequeue_rx(struct altera_tse_private *priv) {struct tse_buffer *buffer =NULL ; + list_remove_head(&priv->rxlisthd, buffer, struct tse_buffer, lh);return buffer; }
@@ -492,6 +491,7 @@ static struct tse_buffer * queue_rx_peekhead(struct altera_tse_private *priv) {struct tse_buffer *buffer =NULL ; + list_peek_head(&priv->rxlisthd, buffer, struct tse_buffer, lh);return buffer; }
drivers/net/ethernet/altera/altera_tse_main.c +3 -6
@@ -258,14 +258,12 @@ static int alloc_init_skbufs(struct altera_tse_private *priv)int i;/* Create Rx ring buffer */ - priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ), -GFP_KERNEL ); + priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ),GFP_KERNEL );if (!priv->rx_ring) goto err_rx_ring;/* Create Tx ring buffer */ - priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ), -GFP_KERNEL ); + priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ),GFP_KERNEL );if (!priv->tx_ring) goto err_tx_ring;
@@ -319,8 +317,7 @@ static inline void tse_rx_refill(struct altera_tse_private *priv)unsigned int entry;int ret; -for (; priv->rx_cons - priv->rx_prod >0 ; - priv->rx_prod++) { +for (; priv->rx_cons - priv->rx_prod >0 ; priv->rx_prod++) { entry = priv->rx_prod % rxsize;if (likely (priv->rx_ring[entry].skb ==NULL )) { ret = tse_init_rx_buffer(priv, &priv->rx_ring[entry],
--
2.26.2
PATCH 3/5 net: ethernet: altera: move read write functions
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Move read write functions from altera_tse.h to altera_utils.h so it can be shared with future altera ethernet IP's.
--- drivers/net/ethernet/altera/altera_tse.h | 45 ------------------- .../net/ethernet/altera/altera_tse_ethtool.c | 1 + drivers/net/ethernet/altera/altera_utils.h | 43 ++++++++++++++++++ 3 files changed, 44 insertions(+), 45 deletions(-)
drivers/net/ethernet/altera/altera_tse.h +0 -45
@@ -483,49 +483,4 @@ struct altera_tse_private {*/ void altera_tse_set_ethtool_ops (struct net_device *); -static inline -u32 csrrd32 (void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); -return readl (paddr); -} - -static inline -u16 csrrd16 (void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); -return readw (paddr); -} - -static inline -u8 csrrd8 (void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); -return readb (paddr); -} - -static inline -void csrwr32 (u32 val,void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); - -writel (val, paddr); -} - -static inline -void csrwr16 (u16 val,void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); - -writew (val, paddr); -} - -static inline -void csrwr8 (u8 val,void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); - -writeb (val, paddr); -} -#endif /* __ALTERA_TSE_H__ */
drivers/net/ethernet/altera/altera_tse_ethtool.c +1 -0
@@ -22,6 +22,7 @@#include <linux/phy.h> #include "altera_tse.h" +#include "altera_utils.h" #define TSE_STATS_LEN 31#define TSE_NUM_REGS 128
drivers/net/ethernet/altera/altera_utils.h +43 -0
53 lines not on this page · raw message
--
2.26.2
Re: [PATCH 3/5] net: ethernet: altera: move read write functions
Quoted 7 lines · On Wed, Dec 13, 2023 at 03:11:10PM +0800, [email protected] wrote:
From: Nagaraju DeepakX <[email protected]>
Move read write functions from
altera_tse.htoaltera_utils.hso it can be shared with future altera ethernet IP's.Signed-off-by Nagaraju DeepakX <[email protected]>Reviewed-by Andy Schevchenko <[email protected]>
PATCH 4/5 net: ethernet: altera: sorting headers in alphabetical order
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Re-arrange the headers in alphabetical order and add empty lines in between of groups of headers for easier maintenance.
--- drivers/net/ethernet/altera/altera_msgdma.c | 7 ++++--- drivers/net/ethernet/altera/altera_sgdma.c | 7 ++++--- drivers/net/ethernet/altera/altera_tse_main.c | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-)
drivers/net/ethernet/altera/altera_msgdma.c +4 -3
@@ -4,10 +4,11 @@*/ #include <linux/netdevice.h> -#include "altera_utils.h" -#include "altera_tse.h" -#include "altera_msgdmahw.h" +#include "altera_msgdma.h" +#include "altera_msgdmahw.h" +#include "altera_tse.h" +#include "altera_utils.h" /* No initialization work to do for MSGDMA */ int msgdma_initialize (struct altera_tse_private *priv)
drivers/net/ethernet/altera/altera_sgdma.c +4 -3
@@ -4,10 +4,11 @@*/ #include <linux/list.h> -#include "altera_utils.h" -#include "altera_tse.h" -#include "altera_sgdmahw.h" +#include "altera_sgdma.h" +#include "altera_sgdmahw.h" +#include "altera_tse.h" +#include "altera_utils.h" static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, struct sgdma_descrip __iomem *ndesc,
drivers/net/ethernet/altera/altera_tse_main.c +4 -3
@@ -38,12 +38,13 @@#include <linux/property.h> #include <linux/regmap.h> #include <linux/skbuff.h> +#include <asm/cacheflush.h> -#include "altera_utils.h" -#include "altera_tse.h" -#include "altera_sgdma.h" #include "altera_msgdma.h" +#include "altera_sgdma.h" +#include "altera_tse.h" +#include "altera_utils.h" static atomic_t instance_count =ATOMIC_INIT (~0 );/* Module parameters */
--
2.26.2
Jakub Kicinski
maintainerRe: [PATCH 4/5] net: ethernet: altera: sorting headers in alphabetical order
Quoted 4 lines · On Wed, 13 Dec 2023 15:11:11 +0800 [email protected] wrote:
From: Nagaraju DeepakX <[email protected]>
Re-arrange the headers in alphabetical order and add empty lines in between of groups of headers for easier maintenance.
This breaks the build, please make sure allmodconfig build works.
Signature · 1 line
pw-bot: cr
PATCH 5/5 net: ethernet: altera: rename functions and their prototypes
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Move standard DMA interface for sgdma and msgdma and rename them from tse_private to dma_private.
--- drivers/net/ethernet/altera/Makefile | 5 +- drivers/net/ethernet/altera/altera_eth_dma.c | 58 +++++ drivers/net/ethernet/altera/altera_eth_dma.h | 121 +++++++++ drivers/net/ethernet/altera/altera_msgdma.c | 31 +-- drivers/net/ethernet/altera/altera_msgdma.h | 28 +- drivers/net/ethernet/altera/altera_sgdma.c | 105 ++++---- drivers/net/ethernet/altera/altera_sgdma.h | 30 +-- drivers/net/ethernet/altera/altera_tse.h | 26 +- .../net/ethernet/altera/altera_tse_ethtool.c | 1 + drivers/net/ethernet/altera/altera_tse_main.c | 241 +++++++----------- drivers/net/ethernet/altera/altera_utils.c | 1 + 11 files changed, 379 insertions(+), 268 deletions(-) create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.c create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.h
drivers/net/ethernet/altera/Makefile +4 -1
@@ -3,6 +3,9 @@ # Makefile for the Altera device drivers. # +ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=NET_ALTERA + obj-$(CONFIG_ALTERA_TSE) += altera_tse.o altera_tse-objs := altera_tse_main.o altera_tse_ethtool.o \ -altera_msgdma.o altera_sgdma.o altera_utils.o + altera_msgdma.o altera_sgdma.o altera_utils.o \ + altera_eth_dma.o
drivers/net/ethernet/altera/altera_eth_dma.c new file +58 -0
58 lines not on this page · raw message
drivers/net/ethernet/altera/altera_eth_dma.h new file +121 -0
121 lines not on this page · raw message
drivers/net/ethernet/altera/altera_msgdma.c +16 -15
@@ -5,26 +5,27 @@#include <linux/netdevice.h> +#include "altera_eth_dma.h" #include "altera_msgdma.h" #include "altera_msgdmahw.h" #include "altera_tse.h" #include "altera_utils.h" /* No initialization work to do for MSGDMA */ -int msgdma_initialize (struct altera_tse_private *priv) +int msgdma_initialize (struct altera_dma_private *priv) {return 0 ; } -void msgdma_uninitialize (struct altera_tse_private *priv) +void msgdma_uninitialize (struct altera_dma_private *priv) { } -void msgdma_start_rxdma (struct altera_tse_private *priv) +void msgdma_start_rxdma (struct altera_dma_private *priv) { } -void msgdma_reset (struct altera_tse_private *priv) +void msgdma_reset (struct altera_dma_private *priv) {int counter;
@@ -72,42 +73,42 @@ void msgdma_reset(struct altera_tse_private *priv)csrwr32 (MSGDMA_CSR_STAT_MASK , priv->tx_dma_csr,msgdma_csroffs (status)); } -void msgdma_disable_rxirq (struct altera_tse_private *priv) +void msgdma_disable_rxirq (struct altera_dma_private *priv) {tse_clear_bit (priv->rx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_enable_rxirq (struct altera_tse_private *priv) +void msgdma_enable_rxirq (struct altera_dma_private *priv) {tse_set_bit (priv->rx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_disable_txirq (struct altera_tse_private *priv) +void msgdma_disable_txirq (struct altera_dma_private *priv) {tse_clear_bit (priv->tx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_enable_txirq (struct altera_tse_private *priv) +void msgdma_enable_txirq (struct altera_dma_private *priv) {tse_set_bit (priv->tx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_clear_rxirq (struct altera_tse_private *priv) +void msgdma_clear_rxirq (struct altera_dma_private *priv) {csrwr32 (MSGDMA_CSR_STAT_IRQ , priv->rx_dma_csr,msgdma_csroffs (status)); } -void msgdma_clear_txirq (struct altera_tse_private *priv) +void msgdma_clear_txirq (struct altera_dma_private *priv) {csrwr32 (MSGDMA_CSR_STAT_IRQ , priv->tx_dma_csr,msgdma_csroffs (status)); }/* return 0 to indicate transmit is pending */ -int msgdma_tx_buffer (struct altera_tse_private *priv,struct tse_buffer *buffer) +int msgdma_tx_buffer (struct altera_dma_private *priv,struct altera_dma_buffer *buffer) {csrwr32 (lower_32_bits (buffer->dma_addr), priv->tx_dma_desc,msgdma_descroffs (read_addr_lo));
@@ -124,7 +125,7 @@ int msgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)return 0 ; } -u32 msgdma_tx_completions (struct altera_tse_private *priv) +u32 msgdma_tx_completions (struct altera_dma_private *priv) {u32 ready =0 ;u32 inuse;
@@ -150,8 +151,8 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv)/* Put buffer to the mSGDMA RX FIFO */ -void msgdma_add_rx_desc (struct altera_tse_private *priv, -struct tse_buffer *rxbuffer) +void msgdma_add_rx_desc (struct altera_dma_private *priv, +struct altera_dma_buffer *rxbuffer) {u32 len = priv->rx_dma_buf_sz;dma_addr_t dma_addr = rxbuffer->dma_addr;
@@ -177,7 +178,7 @@ void msgdma_add_rx_desc(struct altera_tse_private *priv,/* status is returned on upper 16 bits, * length is returned in lower 16 bits */ -u32 msgdma_rx_status (struct altera_tse_private *priv) +u32 msgdma_rx_status (struct altera_dma_private *priv) {u32 rxstatus =0 ;u32 pktlength;
drivers/net/ethernet/altera/altera_msgdma.h +14 -14
@@ -6,19 +6,19 @@#ifndef __ALTERA_MSGDMA_H__#define __ALTERA_MSGDMA_H__ -void msgdma_reset (struct altera_tse_private *); -void msgdma_enable_txirq (struct altera_tse_private *); -void msgdma_enable_rxirq (struct altera_tse_private *); -void msgdma_disable_rxirq (struct altera_tse_private *); -void msgdma_disable_txirq (struct altera_tse_private *); -void msgdma_clear_rxirq (struct altera_tse_private *); -void msgdma_clear_txirq (struct altera_tse_private *); -u32 msgdma_tx_completions (struct altera_tse_private *); -void msgdma_add_rx_desc (struct altera_tse_private *,struct tse_buffer *); -int msgdma_tx_buffer (struct altera_tse_private *,struct tse_buffer *); -u32 msgdma_rx_status (struct altera_tse_private *); -int msgdma_initialize (struct altera_tse_private *); -void msgdma_uninitialize (struct altera_tse_private *); -void msgdma_start_rxdma (struct altera_tse_private *); +void msgdma_reset (struct altera_dma_private *priv); +void msgdma_enable_txirq (struct altera_dma_private *priv); +void msgdma_enable_rxirq (struct altera_dma_private *priv); +void msgdma_disable_rxirq (struct altera_dma_private *priv); +void msgdma_disable_txirq (struct altera_dma_private *priv); +void msgdma_clear_rxirq (struct altera_dma_private *priv); +void msgdma_clear_txirq (struct altera_dma_private *priv); +u32 msgdma_tx_completions (struct altera_dma_private *priv); +void msgdma_add_rx_desc (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +int msgdma_tx_buffer (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +u32 msgdma_rx_status (struct altera_dma_private *priv); +int msgdma_initialize (struct altera_dma_private *priv); +void msgdma_uninitialize (struct altera_dma_private *priv); +void msgdma_start_rxdma (struct altera_dma_private *priv);#endif /* __ALTERA_MSGDMA_H__ */
drivers/net/ethernet/altera/altera_sgdma.c +53 -52
282 lines not on this page · raw message
drivers/net/ethernet/altera/altera_sgdma.h +15 -15
@@ -6,20 +6,20 @@#ifndef __ALTERA_SGDMA_H__#define __ALTERA_SGDMA_H__ -void sgdma_reset (struct altera_tse_private *); -void sgdma_enable_txirq (struct altera_tse_private *); -void sgdma_enable_rxirq (struct altera_tse_private *); -void sgdma_disable_rxirq (struct altera_tse_private *); -void sgdma_disable_txirq (struct altera_tse_private *); -void sgdma_clear_rxirq (struct altera_tse_private *); -void sgdma_clear_txirq (struct altera_tse_private *); -int sgdma_tx_buffer (struct altera_tse_private *priv,struct tse_buffer *); -u32 sgdma_tx_completions (struct altera_tse_private *); -void sgdma_add_rx_desc (struct altera_tse_private *priv,struct tse_buffer *); -void sgdma_status (struct altera_tse_private *); -u32 sgdma_rx_status (struct altera_tse_private *); -int sgdma_initialize (struct altera_tse_private *); -void sgdma_uninitialize (struct altera_tse_private *); -void sgdma_start_rxdma (struct altera_tse_private *); +void sgdma_reset (struct altera_dma_private *priv); +void sgdma_enable_txirq (struct altera_dma_private *priv); +void sgdma_enable_rxirq (struct altera_dma_private *priv); +void sgdma_disable_rxirq (struct altera_dma_private *priv); +void sgdma_disable_txirq (struct altera_dma_private *priv); +void sgdma_clear_rxirq (struct altera_dma_private *priv); +void sgdma_clear_txirq (struct altera_dma_private *priv); +int sgdma_tx_buffer (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +u32 sgdma_tx_completions (struct altera_dma_private *priv); +void sgdma_add_rx_desc (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +void sgdma_status (struct altera_dma_private *priv); +u32 sgdma_rx_status (struct altera_dma_private *priv); +int sgdma_initialize (struct altera_dma_private *priv); +void sgdma_uninitialize (struct altera_dma_private *priv); +void sgdma_start_rxdma (struct altera_dma_private *priv);#endif /* __ALTERA_SGDMA_H__ */
drivers/net/ethernet/altera/altera_tse.h +3 -23
@@ -368,29 +368,6 @@ struct tse_buffer {struct altera_tse_private ; -#define ALTERA_DTYPE_SGDMA 1 -#define ALTERA_DTYPE_MSGDMA 2 - -/* standard DMA interface for SGDMA and MSGDMA */ -struct altera_dmaops { -int altera_dtype; -int dmamask; -void (*reset_dma)(struct altera_tse_private *); -void (*enable_txirq)(struct altera_tse_private *); -void (*enable_rxirq)(struct altera_tse_private *); -void (*disable_txirq)(struct altera_tse_private *); -void (*disable_rxirq)(struct altera_tse_private *); -void (*clear_txirq)(struct altera_tse_private *); -void (*clear_rxirq)(struct altera_tse_private *); -int (*tx_buffer)(struct altera_tse_private *,struct tse_buffer *); -u32 (*tx_completions)(struct altera_tse_private *); -void (*add_rx_desc)(struct altera_tse_private *,struct tse_buffer *); -u32 (*get_rx_status)(struct altera_tse_private *); -int (*init_dma)(struct altera_tse_private *); -void (*uninit_dma)(struct altera_tse_private *); -void (*start_rxdma)(struct altera_tse_private *); -}; -/* This structure is private to each device. */ struct altera_tse_private {
@@ -400,6 +377,9 @@ struct altera_tse_private {/* MAC address space */ struct altera_tse_mac __iomem *mac_dev; + +/* Shared DMA structure */ +struct altera_dma_private dma_priv;/* TSE Revision */ u32 revision;
drivers/net/ethernet/altera/altera_tse_ethtool.c +1 -0
@@ -21,6 +21,7 @@#include <linux/netdevice.h> #include <linux/phy.h> +#include "altera_eth_dma.h" #include "altera_tse.h" #include "altera_utils.h"
drivers/net/ethernet/altera/altera_tse_main.c +93 -148
511 lines not on this page · raw message
drivers/net/ethernet/altera/altera_utils.c +1 -0
@@ -3,6 +3,7 @@* Copyright (C) 2014 Altera Corporation. All rights reserved */ +#include "altera_eth_dma.h" #include "altera_tse.h" #include "altera_utils.h"
--
2.26.2
v2 cover Rename functions and their prototypes and move to common files.
From: Nagaraju DeepakX <[email protected]>
Hi,
Moving the standard DMA interface for SGDMA and MSGDMA and renaming from tse_private to dma_private. Moving read-write function prototypes from altera_tse.h to altera_utils.h. Commonize DMA for upcoming altera Drivers.
Patch1: Removing unneeded assignments.
Patch2: Fixing indentation warnings.
Patch3: Moving read write Function prototypes.
Patch4: Renaming function prototypes.
changelog v2:
* Build issue resolved.
Nagaraju DeepakX (4):
net: ethernet: altera: remove unneeded assignments
net: ethernet: altera: fix indentation warnings
net: ethernet: altera: move read write functions
net: ethernet: altera: rename functions and their prototypes
drivers/net/ethernet/altera/Makefile | 5 +- drivers/net/ethernet/altera/altera_eth_dma.c | 58 ++++ drivers/net/ethernet/altera/altera_eth_dma.h | 121 +++++++++ drivers/net/ethernet/altera/altera_msgdma.c | 38 +-- drivers/net/ethernet/altera/altera_msgdma.h | 28 +- drivers/net/ethernet/altera/altera_sgdma.c | 138 +++++----- drivers/net/ethernet/altera/altera_sgdma.h | 30 +-- drivers/net/ethernet/altera/altera_tse.h | 71 +---- .../net/ethernet/altera/altera_tse_ethtool.c | 2 + drivers/net/ethernet/altera/altera_tse_main.c | 251 +++++++----------- drivers/net/ethernet/altera/altera_utils.c | 1 + drivers/net/ethernet/altera/altera_utils.h | 43 +++ 12 files changed, 447 insertions(+), 339 deletions(-) create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.c create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.h
--
2.26.2
PATCH v2 1/4 net: ethernet: altera: remove unneeded assignments
From: Nagaraju DeepakX <[email protected]>
Remove unneeded assignments in the code.
--- drivers/net/ethernet/altera/altera_sgdma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/altera/altera_sgdma.c +2 -4
@@ -63,8 +63,6 @@ int sgdma_initialize(struct altera_tse_private *priv)INIT_LIST_HEAD (&priv->txlisthd);INIT_LIST_HEAD (&priv->rxlisthd); - priv->rxdescphys = (dma_addr_t )0 ; - priv->txdescphys = (dma_addr_t )0 ; priv->rxdescphys = dma_map_single(priv->device, (void __force *)priv->rx_dma_desc,
@@ -237,8 +235,8 @@ u32 sgdma_rx_status(struct altera_tse_private *priv) desc = &base[0 ];if (sts &SGDMA_STSREG_EOP ) { -unsigned int pktlength =0 ; -unsigned int pktstatus =0 ; +unsigned int pktlength; +unsigned int pktstatus; dma_sync_single_for_cpu(priv->device, priv->rxdescphys, SGDMA_DESC_LEN,
--
2.26.2
PATCH v2 2/4 net: ethernet: altera: fix indentation warnings
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Fix indentation issues such as missing a blank line after declarations and alignment issues.
--- drivers/net/ethernet/altera/altera_sgdma.c | 22 +++++++++---------- drivers/net/ethernet/altera/altera_tse_main.c | 9 +++----- 2 files changed, 14 insertions(+), 17 deletions(-)
drivers/net/ethernet/altera/altera_sgdma.c +11 -11
@@ -20,7 +20,7 @@ static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, int wfixed);static int sgdma_async_write (struct altera_tse_private *priv, -struct sgdma_descrip __iomem *desc); +struct sgdma_descrip __iomem *desc);static int sgdma_async_read (struct altera_tse_private *priv);
@@ -63,7 +63,6 @@ int sgdma_initialize(struct altera_tse_private *priv)INIT_LIST_HEAD (&priv->txlisthd);INIT_LIST_HEAD (&priv->rxlisthd); - priv->rxdescphys =dma_map_single (priv->device, (void __force *)priv->rx_dma_desc, priv->rxdescmem,DMA_BIDIRECTIONAL );
@@ -192,9 +191,7 @@ int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)return 1 ; } - -/* tx_lock held to protect access to queued tx list -*/ +/* tx_lock held to protect access to queued tx list */ u32 sgdma_tx_completions (struct altera_tse_private *priv) {u32 ready =0 ;
@@ -237,10 +234,9 @@ u32 sgdma_rx_status(struct altera_tse_private *priv)if (sts &SGDMA_STSREG_EOP ) {unsigned int pktlength;unsigned int pktstatus; -dma_sync_single_for_cpu (priv->device, - priv->rxdescphys, -SGDMA_DESC_LEN , -DMA_FROM_DEVICE ); + +dma_sync_single_for_cpu (priv->device, priv->rxdescphys, +SGDMA_DESC_LEN ,DMA_FROM_DEVICE ); pktlength =csrrd16 (desc,sgdma_descroffs (bytes_xferred)); pktstatus =csrrd8 (desc,sgdma_descroffs (status));
@@ -286,7 +282,6 @@ u32 sgdma_rx_status(struct altera_tse_private *priv)return rxstatus; } -/* Private functions */ static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, struct sgdma_descrip __iomem *ndesc,
@@ -301,6 +296,7 @@ static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc,/* Clear the next descriptor as not owned by hardware */ u32 ctrl =csrrd8 (ndesc,sgdma_descroffs (control)); + ctrl &= ~SGDMA_CONTROL_HW_OWNED ;csrwr8 (ctrl, ndesc,sgdma_descroffs (control));
@@ -406,6 +402,7 @@ sgdma_txphysaddr(struct altera_tse_private *priv, {dma_addr_t paddr = priv->txdescmem_busaddr;uintptr_t offs = (uintptr_t )desc - (uintptr_t )priv->tx_dma_desc; +return (dma_addr_t)((uintptr_t )paddr + offs); }
@@ -415,6 +412,7 @@ sgdma_rxphysaddr(struct altera_tse_private *priv, {dma_addr_t paddr = priv->rxdescmem_busaddr;uintptr_t offs = (uintptr_t )desc - (uintptr_t )priv->rx_dma_desc; +return (dma_addr_t)((uintptr_t )paddr + offs); }
@@ -445,7 +443,6 @@ queue_tx(struct altera_tse_private *priv, struct tse_buffer *buffer)list_add_tail (&buffer->lh, &priv->txlisthd); } -/* adds a tse_buffer to the tail of a rx buffer list * assumes the caller is managing and holding a mutual exclusion * primitive to avoid simultaneous pushes/pops to the list.
@@ -465,6 +462,7 @@ static struct tse_buffer * dequeue_tx(struct altera_tse_private *priv) {struct tse_buffer *buffer =NULL ; + list_remove_head(&priv->txlisthd, buffer, struct tse_buffer, lh);return buffer; }
@@ -478,6 +476,7 @@ static struct tse_buffer * dequeue_rx(struct altera_tse_private *priv) {struct tse_buffer *buffer =NULL ; + list_remove_head(&priv->rxlisthd, buffer, struct tse_buffer, lh);return buffer; }
@@ -492,6 +491,7 @@ static struct tse_buffer * queue_rx_peekhead(struct altera_tse_private *priv) {struct tse_buffer *buffer =NULL ; + list_peek_head(&priv->rxlisthd, buffer, struct tse_buffer, lh);return buffer; }
drivers/net/ethernet/altera/altera_tse_main.c +3 -6
@@ -258,14 +258,12 @@ static int alloc_init_skbufs(struct altera_tse_private *priv)int i;/* Create Rx ring buffer */ - priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ), -GFP_KERNEL ); + priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ),GFP_KERNEL );if (!priv->rx_ring) goto err_rx_ring;/* Create Tx ring buffer */ - priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ), -GFP_KERNEL ); + priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ),GFP_KERNEL );if (!priv->tx_ring) goto err_tx_ring;
@@ -319,8 +317,7 @@ static inline void tse_rx_refill(struct altera_tse_private *priv)unsigned int entry;int ret; -for (; priv->rx_cons - priv->rx_prod >0 ; - priv->rx_prod++) { +for (; priv->rx_cons - priv->rx_prod >0 ; priv->rx_prod++) { entry = priv->rx_prod % rxsize;if (likely (priv->rx_ring[entry].skb ==NULL )) { ret = tse_init_rx_buffer(priv, &priv->rx_ring[entry],
--
2.26.2
Simon Horman
reviewerRe: [PATCH v2 2/4] net: ethernet: altera: fix indentation warnings
Quoted 7 lines · On Thu, Dec 21, 2023 at 09:40:39PM +0800, [email protected] wrote:
From: Nagaraju DeepakX <[email protected]>
Fix indentation issues such as missing a blank line after declarations and alignment issues.
Signed-off-by Nagaraju DeepakX <[email protected]>Reviewed-by Andy Schevchenko <[email protected]>
...
Quoted 8 lines
drivers/net/ethernet/altera/altera_tse_main.c +0
-0@@ -258,14 +258,12 @@ static int alloc_init_skbufs(struct altera_tse_private *priv)int i;/* Create Rx ring buffer */
drivers/net/ethernet/altera/altera_tse_main.c static int alloc_init_skbufs(struct altera_tse_private *priv) · line 266
Quoted 10 lines
drivers/net/ethernet/altera/altera_tse_main.c +2
-4- priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ), -GFP_KERNEL ); + priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ),GFP_KERNEL );if (!priv->rx_ring) goto err_rx_ring;/* Create Tx ring buffer */ - priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ), -GFP_KERNEL ); + priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ),GFP_KERNEL );
Hi,
Networking still prefers code that is less than 80 columns wide. So I think the above changes are not desirable.
The rest of the patch looks find to me, assuming the maintainers want to take cosmetic changes of this nature. Which, personally, I lean to thinking is ok in the context of the rest of this patch-set.
Quoted 3 lines
drivers/net/ethernet/altera/altera_tse_main.c +0
-0if (!priv->tx_ring) goto err_tx_ring;
...
PATCH v2 3/4 net: ethernet: altera: move read write functions
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Move read write functions from altera_tse.h to altera_utils.h so it can be shared with future altera ethernet IP's.
--- drivers/net/ethernet/altera/altera_tse.h | 45 ------------------- .../net/ethernet/altera/altera_tse_ethtool.c | 1 + drivers/net/ethernet/altera/altera_utils.h | 43 ++++++++++++++++++ 3 files changed, 44 insertions(+), 45 deletions(-)
drivers/net/ethernet/altera/altera_tse.h +0 -45
@@ -483,49 +483,4 @@ struct altera_tse_private {*/ void altera_tse_set_ethtool_ops (struct net_device *); -static inline -u32 csrrd32 (void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); -return readl (paddr); -} - -static inline -u16 csrrd16 (void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); -return readw (paddr); -} - -static inline -u8 csrrd8 (void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); -return readb (paddr); -} - -static inline -void csrwr32 (u32 val,void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); - -writel (val, paddr); -} - -static inline -void csrwr16 (u16 val,void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); - -writew (val, paddr); -} - -static inline -void csrwr8 (u8 val,void __iomem *mac,size_t offs) -{ -void __iomem *paddr = (void __iomem *)((uintptr_t )mac + offs); - -writeb (val, paddr); -} -#endif /* __ALTERA_TSE_H__ */
drivers/net/ethernet/altera/altera_tse_ethtool.c +1 -0
@@ -22,6 +22,7 @@#include <linux/phy.h> #include "altera_tse.h" +#include "altera_utils.h" #define TSE_STATS_LEN 31#define TSE_NUM_REGS 128
drivers/net/ethernet/altera/altera_utils.h +43 -0
53 lines not on this page · raw message
--
2.26.2
PATCH v2 4/4 net: ethernet: altera: rename functions and their prototypes
In reply to [email protected]From: Nagaraju DeepakX <[email protected]>
Move standard DMA interface for sgdma and msgdma and rename them from tse_private to dma_private.
--- drivers/net/ethernet/altera/Makefile | 5 +- drivers/net/ethernet/altera/altera_eth_dma.c | 58 ++++ drivers/net/ethernet/altera/altera_eth_dma.h | 121 +++++++++ drivers/net/ethernet/altera/altera_msgdma.c | 38 +-- drivers/net/ethernet/altera/altera_msgdma.h | 28 +- drivers/net/ethernet/altera/altera_sgdma.c | 110 ++++---- drivers/net/ethernet/altera/altera_sgdma.h | 30 +-- drivers/net/ethernet/altera/altera_tse.h | 26 +- .../net/ethernet/altera/altera_tse_ethtool.c | 1 + drivers/net/ethernet/altera/altera_tse_main.c | 248 +++++++----------- drivers/net/ethernet/altera/altera_utils.c | 1 + 11 files changed, 390 insertions(+), 276 deletions(-) create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.c create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.h
drivers/net/ethernet/altera/Makefile +4 -1
@@ -3,6 +3,9 @@ # Makefile for the Altera device drivers. # +ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=NET_ALTERA + obj-$(CONFIG_ALTERA_TSE) += altera_tse.o altera_tse-objs := altera_tse_main.o altera_tse_ethtool.o \ -altera_msgdma.o altera_sgdma.o altera_utils.o + altera_msgdma.o altera_sgdma.o altera_utils.o \ + altera_eth_dma.o
drivers/net/ethernet/altera/altera_eth_dma.c new file +58 -0
58 lines not on this page · raw message
drivers/net/ethernet/altera/altera_eth_dma.h new file +121 -0
121 lines not on this page · raw message
drivers/net/ethernet/altera/altera_msgdma.c +20 -18
@@ -4,26 +4,28 @@*/ #include <linux/netdevice.h> -#include "altera_utils.h" -#include "altera_tse.h" -#include "altera_msgdmahw.h" + +#include "altera_eth_dma.h" #include "altera_msgdma.h" +#include "altera_msgdmahw.h" +#include "altera_tse.h" +#include "altera_utils.h" /* No initialization work to do for MSGDMA */ -int msgdma_initialize (struct altera_tse_private *priv) +int msgdma_initialize (struct altera_dma_private *priv) {return 0 ; } -void msgdma_uninitialize (struct altera_tse_private *priv) +void msgdma_uninitialize (struct altera_dma_private *priv) { } -void msgdma_start_rxdma (struct altera_tse_private *priv) +void msgdma_start_rxdma (struct altera_dma_private *priv) { } -void msgdma_reset (struct altera_tse_private *priv) +void msgdma_reset (struct altera_dma_private *priv) {int counter;
@@ -71,42 +73,42 @@ void msgdma_reset(struct altera_tse_private *priv)csrwr32 (MSGDMA_CSR_STAT_MASK , priv->tx_dma_csr,msgdma_csroffs (status)); } -void msgdma_disable_rxirq (struct altera_tse_private *priv) +void msgdma_disable_rxirq (struct altera_dma_private *priv) {tse_clear_bit (priv->rx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_enable_rxirq (struct altera_tse_private *priv) +void msgdma_enable_rxirq (struct altera_dma_private *priv) {tse_set_bit (priv->rx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_disable_txirq (struct altera_tse_private *priv) +void msgdma_disable_txirq (struct altera_dma_private *priv) {tse_clear_bit (priv->tx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_enable_txirq (struct altera_tse_private *priv) +void msgdma_enable_txirq (struct altera_dma_private *priv) {tse_set_bit (priv->tx_dma_csr,msgdma_csroffs (control),MSGDMA_CSR_CTL_GLOBAL_INTR ); } -void msgdma_clear_rxirq (struct altera_tse_private *priv) +void msgdma_clear_rxirq (struct altera_dma_private *priv) {csrwr32 (MSGDMA_CSR_STAT_IRQ , priv->rx_dma_csr,msgdma_csroffs (status)); } -void msgdma_clear_txirq (struct altera_tse_private *priv) +void msgdma_clear_txirq (struct altera_dma_private *priv) {csrwr32 (MSGDMA_CSR_STAT_IRQ , priv->tx_dma_csr,msgdma_csroffs (status)); }/* return 0 to indicate transmit is pending */ -int msgdma_tx_buffer (struct altera_tse_private *priv,struct tse_buffer *buffer) +int msgdma_tx_buffer (struct altera_dma_private *priv,struct altera_dma_buffer *buffer) {csrwr32 (lower_32_bits (buffer->dma_addr), priv->tx_dma_desc,msgdma_descroffs (read_addr_lo));
@@ -123,7 +125,7 @@ int msgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)return 0 ; } -u32 msgdma_tx_completions (struct altera_tse_private *priv) +u32 msgdma_tx_completions (struct altera_dma_private *priv) {u32 ready =0 ;u32 inuse;
@@ -149,8 +151,8 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv)/* Put buffer to the mSGDMA RX FIFO */ -void msgdma_add_rx_desc (struct altera_tse_private *priv, -struct tse_buffer *rxbuffer) +void msgdma_add_rx_desc (struct altera_dma_private *priv, +struct altera_dma_buffer *rxbuffer) {u32 len = priv->rx_dma_buf_sz;dma_addr_t dma_addr = rxbuffer->dma_addr;
@@ -176,7 +178,7 @@ void msgdma_add_rx_desc(struct altera_tse_private *priv,/* status is returned on upper 16 bits, * length is returned in lower 16 bits */ -u32 msgdma_rx_status (struct altera_tse_private *priv) +u32 msgdma_rx_status (struct altera_dma_private *priv) {u32 rxstatus =0 ;u32 pktlength;
drivers/net/ethernet/altera/altera_msgdma.h +14 -14
@@ -6,19 +6,19 @@#ifndef __ALTERA_MSGDMA_H__#define __ALTERA_MSGDMA_H__ -void msgdma_reset (struct altera_tse_private *); -void msgdma_enable_txirq (struct altera_tse_private *); -void msgdma_enable_rxirq (struct altera_tse_private *); -void msgdma_disable_rxirq (struct altera_tse_private *); -void msgdma_disable_txirq (struct altera_tse_private *); -void msgdma_clear_rxirq (struct altera_tse_private *); -void msgdma_clear_txirq (struct altera_tse_private *); -u32 msgdma_tx_completions (struct altera_tse_private *); -void msgdma_add_rx_desc (struct altera_tse_private *,struct tse_buffer *); -int msgdma_tx_buffer (struct altera_tse_private *,struct tse_buffer *); -u32 msgdma_rx_status (struct altera_tse_private *); -int msgdma_initialize (struct altera_tse_private *); -void msgdma_uninitialize (struct altera_tse_private *); -void msgdma_start_rxdma (struct altera_tse_private *); +void msgdma_reset (struct altera_dma_private *priv); +void msgdma_enable_txirq (struct altera_dma_private *priv); +void msgdma_enable_rxirq (struct altera_dma_private *priv); +void msgdma_disable_rxirq (struct altera_dma_private *priv); +void msgdma_disable_txirq (struct altera_dma_private *priv); +void msgdma_clear_rxirq (struct altera_dma_private *priv); +void msgdma_clear_txirq (struct altera_dma_private *priv); +u32 msgdma_tx_completions (struct altera_dma_private *priv); +void msgdma_add_rx_desc (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +int msgdma_tx_buffer (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +u32 msgdma_rx_status (struct altera_dma_private *priv); +int msgdma_initialize (struct altera_dma_private *priv); +void msgdma_uninitialize (struct altera_dma_private *priv); +void msgdma_start_rxdma (struct altera_dma_private *priv);#endif /* __ALTERA_MSGDMA_H__ */
drivers/net/ethernet/altera/altera_sgdma.c +56 -54
285 lines not on this page · raw message
drivers/net/ethernet/altera/altera_sgdma.h +15 -15
@@ -6,20 +6,20 @@#ifndef __ALTERA_SGDMA_H__#define __ALTERA_SGDMA_H__ -void sgdma_reset (struct altera_tse_private *); -void sgdma_enable_txirq (struct altera_tse_private *); -void sgdma_enable_rxirq (struct altera_tse_private *); -void sgdma_disable_rxirq (struct altera_tse_private *); -void sgdma_disable_txirq (struct altera_tse_private *); -void sgdma_clear_rxirq (struct altera_tse_private *); -void sgdma_clear_txirq (struct altera_tse_private *); -int sgdma_tx_buffer (struct altera_tse_private *priv,struct tse_buffer *); -u32 sgdma_tx_completions (struct altera_tse_private *); -void sgdma_add_rx_desc (struct altera_tse_private *priv,struct tse_buffer *); -void sgdma_status (struct altera_tse_private *); -u32 sgdma_rx_status (struct altera_tse_private *); -int sgdma_initialize (struct altera_tse_private *); -void sgdma_uninitialize (struct altera_tse_private *); -void sgdma_start_rxdma (struct altera_tse_private *); +void sgdma_reset (struct altera_dma_private *priv); +void sgdma_enable_txirq (struct altera_dma_private *priv); +void sgdma_enable_rxirq (struct altera_dma_private *priv); +void sgdma_disable_rxirq (struct altera_dma_private *priv); +void sgdma_disable_txirq (struct altera_dma_private *priv); +void sgdma_clear_rxirq (struct altera_dma_private *priv); +void sgdma_clear_txirq (struct altera_dma_private *priv); +int sgdma_tx_buffer (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +u32 sgdma_tx_completions (struct altera_dma_private *priv); +void sgdma_add_rx_desc (struct altera_dma_private *priv,struct altera_dma_buffer *buffer); +void sgdma_status (struct altera_dma_private *priv); +u32 sgdma_rx_status (struct altera_dma_private *priv); +int sgdma_initialize (struct altera_dma_private *priv); +void sgdma_uninitialize (struct altera_dma_private *priv); +void sgdma_start_rxdma (struct altera_dma_private *priv);#endif /* __ALTERA_SGDMA_H__ */
drivers/net/ethernet/altera/altera_tse.h +3 -23
@@ -368,29 +368,6 @@ struct tse_buffer {struct altera_tse_private ; -#define ALTERA_DTYPE_SGDMA 1 -#define ALTERA_DTYPE_MSGDMA 2 - -/* standard DMA interface for SGDMA and MSGDMA */ -struct altera_dmaops { -int altera_dtype; -int dmamask; -void (*reset_dma)(struct altera_tse_private *); -void (*enable_txirq)(struct altera_tse_private *); -void (*enable_rxirq)(struct altera_tse_private *); -void (*disable_txirq)(struct altera_tse_private *); -void (*disable_rxirq)(struct altera_tse_private *); -void (*clear_txirq)(struct altera_tse_private *); -void (*clear_rxirq)(struct altera_tse_private *); -int (*tx_buffer)(struct altera_tse_private *,struct tse_buffer *); -u32 (*tx_completions)(struct altera_tse_private *); -void (*add_rx_desc)(struct altera_tse_private *,struct tse_buffer *); -u32 (*get_rx_status)(struct altera_tse_private *); -int (*init_dma)(struct altera_tse_private *); -void (*uninit_dma)(struct altera_tse_private *); -void (*start_rxdma)(struct altera_tse_private *); -}; -/* This structure is private to each device. */ struct altera_tse_private {
@@ -401,6 +378,9 @@ struct altera_tse_private {/* MAC address space */ struct altera_tse_mac __iomem *mac_dev; +/* Shared DMA structure */ +struct altera_dma_private dma_priv; +/* TSE Revision */ u32 revision;
drivers/net/ethernet/altera/altera_tse_ethtool.c +1 -0
@@ -21,6 +21,7 @@#include <linux/netdevice.h> #include <linux/phy.h> +#include "altera_eth_dma.h" #include "altera_tse.h" #include "altera_utils.h"
drivers/net/ethernet/altera/altera_tse_main.c +97 -151
518 lines not on this page · raw message
drivers/net/ethernet/altera/altera_utils.c +1 -0
@@ -3,6 +3,7 @@* Copyright (C) 2014 Altera Corporation. All rights reserved */ +#include "altera_eth_dma.h" #include "altera_tse.h" #include "altera_utils.h"
--
2.26.2
Simon Horman
reviewerRe: [PATCH v2 4/4] net: ethernet: altera: rename functions and their prototypes
Quoted 7 lines · On Thu, Dec 21, 2023 at 09:40:41PM +0800, [email protected] wrote:
From: Nagaraju DeepakX <[email protected]>
Move standard DMA interface for sgdma and msgdma and rename them from
tse_privatetodma_private.Signed-off-by Nagaraju DeepakX <[email protected]>Reviewed-by Andy Schevchenko <[email protected]>
Quoted 15 lines
--- drivers/net/ethernet/altera/Makefile | 5 +- drivers/net/ethernet/altera/altera_eth_dma.c | 58 ++++ drivers/net/ethernet/altera/altera_eth_dma.h | 121 +++++++++ drivers/net/ethernet/altera/altera_msgdma.c | 38 +-- drivers/net/ethernet/altera/altera_msgdma.h | 28 +- drivers/net/ethernet/altera/altera_sgdma.c | 110 ++++---- drivers/net/ethernet/altera/altera_sgdma.h | 30 +-- drivers/net/ethernet/altera/altera_tse.h | 26 +- .../net/ethernet/altera/altera_tse_ethtool.c | 1 + drivers/net/ethernet/altera/altera_tse_main.c | 248 +++++++----------- drivers/net/ethernet/altera/altera_utils.c | 1 + 11 files changed, 390 insertions(+), 276 deletions(-) create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.c create mode 100644 drivers/net/ethernet/altera/altera_eth_dma.h
Hi Nagaraju,
this patch is doing a lot of things. I think that the patch description warrants a description of why this is desirable.
And I think it would also be worth consider breaking it up: doing one thing at a time makes things a lot easier to review (for me at least).
Quoted 69 lines
drivers/net/ethernet/altera/Makefile +4
-1@@ -3,6 +3,9 @@ # Makefile for the Altera device drivers. # +ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=NET_ALTERA + obj-$(CONFIG_ALTERA_TSE) += altera_tse.o altera_tse-objs := altera_tse_main.o altera_tse_ethtool.o \ -altera_msgdma.o altera_sgdma.o altera_utils.o + altera_msgdma.o altera_sgdma.o altera_utils.o \ + altera_eth_dma.odrivers/net/ethernet/altera/altera_eth_dma.c new file +47
-0@@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* DMA support for Intel FPGA Quad-Speed Ethernet MAC driver +* Copyright (C) 2023 Intel Corporation. All rights reserved +*/ + +#include <linux/errno.h> +#include <linux/export.h> +#include <linux/io.h> +#include <linux/platform_device.h> + +#include "altera_eth_dma.h" +#include "altera_utils.h" + +/* Probe DMA */ +int altera_eth_dma_probe (struct platform_device *pdev,struct altera_dma_private *priv, +enum altera_dma_type type) +{ +void __iomem *descmap; + +/* xSGDMA Rx Dispatcher address space */ + priv->rx_dma_csr =devm_platform_ioremap_resource_byname (pdev,"rx_csr" ); +if (IS_ERR (priv->rx_dma_csr)) +return PTR_ERR (priv->rx_dma_csr); + +/* mSGDMA Tx Dispatcher address space */ + priv->tx_dma_csr =devm_platform_ioremap_resource_byname (pdev,"tx_csr" ); +if (IS_ERR (priv->rx_dma_csr)) +return PTR_ERR (priv->rx_dma_csr); + +switch (type) { +case ALTERA_DTYPE_SGDMA : +/* Get the mapped address to the SGDMA descriptor memory */ + descmap =devm_platform_ioremap_resource_byname (pdev,"s1" ); +if (IS_ERR (descmap)) +return PTR_ERR (descmap); +break ; +case ALTERA_DTYPE_MSGDMA : + priv->rx_dma_resp =devm_platform_ioremap_resource_byname (pdev,"rx_resp" ); +if (IS_ERR (priv->rx_dma_resp)) +return PTR_ERR (priv->rx_dma_resp); + + priv->tx_dma_desc =devm_platform_ioremap_resource_byname (pdev,"tx_desc" ); +if (IS_ERR (priv->tx_dma_desc)) +return PTR_ERR (priv->tx_dma_desc); + + priv->rx_dma_desc =devm_platform_ioremap_resource_byname (pdev,"rx_desc" ); +if (IS_ERR (priv->rx_dma_desc))
drivers/net/ethernet/altera/altera_eth_dma.c line 57
Quoted 10 lines
drivers/net/ethernet/altera/altera_eth_dma.c new file +10
-0+return PTR_ERR (priv->rx_dma_desc); +break ; +default : +return -ENODEV ; + } + +return 0 ; + +}; +EXPORT_SYMBOL_NS (altera_eth_dma_probe,NET_ALTERA );
Perhaps I am missing something obvious here, but, I'm a little confused by this export; And the corresponding import in altera_tse_main; And the MODULE_LICENSE below, as there is also a MODULE_LICENSE in corresponding import in altera_tse_main.c.
The basis of my confusion is that I assume that this file and altera_tse_main.c are both parts of the same module.
Quoted 1 line
drivers/net/ethernet/altera/altera_eth_dma.c new file +1
-0+MODULE_LICENSE ("GPL" );
...
drivers/net/ethernet/altera/altera_tse.h struct tse_buffer { · line 369
Quoted 7 lines
drivers/net/ethernet/altera/altera_tse.h +0
-0@@ -368,29 +368,6 @@ struct tse_buffer {struct altera_tse_private ;
I think the forward declaration of struct altera_tse_private can also be removed.
Quoted 28 lines
drivers/net/ethernet/altera/altera_tse.h +0
-23-#define ALTERA_DTYPE_SGDMA 1 -#define ALTERA_DTYPE_MSGDMA 2 - -/* standard DMA interface for SGDMA and MSGDMA */ -struct altera_dmaops { -int altera_dtype; -int dmamask; -void (*reset_dma)(struct altera_tse_private *); -void (*enable_txirq)(struct altera_tse_private *); -void (*enable_rxirq)(struct altera_tse_private *); -void (*disable_txirq)(struct altera_tse_private *); -void (*disable_rxirq)(struct altera_tse_private *); -void (*clear_txirq)(struct altera_tse_private *); -void (*clear_rxirq)(struct altera_tse_private *); -int (*tx_buffer)(struct altera_tse_private *,struct tse_buffer *); -u32 (*tx_completions)(struct altera_tse_private *); -void (*add_rx_desc)(struct altera_tse_private *,struct tse_buffer *); -u32 (*get_rx_status)(struct altera_tse_private *); -int (*init_dma)(struct altera_tse_private *); -void (*uninit_dma)(struct altera_tse_private *); -void (*start_rxdma)(struct altera_tse_private *); -}; -/* This structure is private to each device. */ struct altera_tse_private {
drivers/net/ethernet/altera/altera_tse.h struct altera_tse_private { · line 382
Quoted 5 lines
drivers/net/ethernet/altera/altera_tse.h +2
-0@@ -401,6 +378,9 @@ struct altera_tse_private {/* MAC address space */ struct altera_tse_mac __iomem *mac_dev; +/* Shared DMA structure */ +struct altera_dma_private dma_priv;
I had expected many of the fields corresponding to those present in struct altera_dma_private to be removed from struct altera_tse_private.
Quoted 9 lines
drivers/net/ethernet/altera/altera_tse.h +1
-0+/* TSE Revision */ u32 revision;drivers/net/ethernet/altera/altera_tse_ethtool.c +0
-0
drivers/net/ethernet/altera/altera_tse_ethtool.c line 26
Quoted 6 lines
drivers/net/ethernet/altera/altera_tse_ethtool.c +1
-0@@ -21,6 +21,7 @@#include <linux/netdevice.h> #include <linux/phy.h> +#include "altera_eth_dma.h" #include "altera_tse.h" #include "altera_utils.h"
This seems wrong.
Headers should, in general, include everything they need to be included by .c files.
I think that here altera_eth_dma.h should be included in altera_tse.h.
Quoted 20 lines
drivers/net/ethernet/altera/altera_tse_main.c +3
-2@@ -29,21 +29,23 @@#include <linux/mii.h> #include <linux/mdio/mdio-regmap.h> #include <linux/netdevice.h> -#include <linux/of.h> +#include <linux/of_device.h> #include <linux/of_mdio.h> #include <linux/of_net.h> +#include <linux/of_platform.h> #include <linux/pcs-lynx.h> #include <linux/phy.h> #include <linux/platform_device.h> -#include <linux/property.h> #include <linux/regmap.h> #include <linux/skbuff.h> +
drivers/net/ethernet/altera/altera_tse_main.c line 48
Quoted 10 lines
drivers/net/ethernet/altera/altera_tse_main.c +4
-3#include <asm/cacheflush.h> -#include "altera_utils.h" -#include "altera_tse.h" -#include "altera_sgdma.h" +#include "altera_eth_dma.h" #include "altera_msgdma.h" +#include "altera_sgdma.h" +#include "altera_tse.h" +#include "altera_utils.h"
I'm all for cleaning up includes, but are the changes above strictly related to the rest of this patch? If not, perhaps they could be moved into a separate patch.
...
Quoted 11 lines
drivers/net/ethernet/altera/altera_tse_main.c +1
-0@@ -1529,4 +1474,5 @@ module_platform_driver(altera_tse_driver);MODULE_AUTHOR ("Altera Corporation" );MODULE_DESCRIPTION ("Altera Triple Speed Ethernet MAC driver" ); +MODULE_IMPORT_NS (NET_ALTERA );MODULE_LICENSE ("GPL v2" );drivers/net/ethernet/altera/altera_utils.c +0
-0
drivers/net/ethernet/altera/altera_utils.c line 8
Quoted 6 lines
drivers/net/ethernet/altera/altera_utils.c +1
-0@@ -3,6 +3,7 @@* Copyright (C) 2014 Altera Corporation. All rights reserved */ +#include "altera_eth_dma.h" #include "altera_tse.h" #include "altera_utils.h"
Please see my comment on altera_tse_ethtool.c,
I believe it applies here too.
Simon Horman
reviewerRe: [PATCH v2 4/4] net: ethernet: altera: rename functions and their prototypes
In reply to [email protected]Quoted 7 lines · On Thu, Dec 21, 2023 at 09:40:41PM +0800, [email protected] wrote:
From: Nagaraju DeepakX <[email protected]>
Move standard DMA interface for sgdma and msgdma and rename them from
tse_privatetodma_private.Signed-off-by Nagaraju DeepakX <[email protected]>Reviewed-by Andy Schevchenko <[email protected]>
...
Quoted 1 line
drivers/net/ethernet/altera/altera_tse_main.c +0
-0
...
Quoted 6 lines
drivers/net/ethernet/altera/altera_tse_main.c +0
-2@@ -252,42 +256,42 @@ static void tse_free_tx_buffer(struct altera_tse_private *priv,static int alloc_init_skbufs (struct altera_tse_private *priv) { -unsigned int rx_descs = priv->rx_ring_size; -unsigned int tx_descs = priv->tx_ring_size;
drivers/net/ethernet/altera/altera_tse_main.c static void tse_free_tx_buffer(struct altera_tse_private *priv, · line 266
Quoted 10 lines
drivers/net/ethernet/altera/altera_tse_main.c +4
-2+struct altera_dma_private *dma = &priv->dma_priv; +unsigned int rx_descs = dma->rx_ring_size; +unsigned int tx_descs = dma->tx_ring_size;int ret = -ENOMEM ;int i;/* Create Rx ring buffer */ - priv->rx_ring =kcalloc (rx_descs,sizeof (struct tse_buffer ),GFP_KERNEL ); -if (!priv->rx_ring) + dma->rx_ring =kcalloc (rx_descs,sizeof (struct altera_dma_private ),GFP_KERNEL );
Hi Nagaraju,
Sorry, I didn't notice this until after I sent my previous review to this patch.
Is struct altera_dma_private correct on the line above? It seems to me that it should, rather, be struct altera_dma_buffer. Likewise a few lines below.
Flagged by Smatch.
Quoted 43 lines
drivers/net/ethernet/altera/altera_tse_main.c +11
-11+if (!dma->rx_ring) goto err_rx_ring;/* Create Tx ring buffer */ - priv->tx_ring =kcalloc (tx_descs,sizeof (struct tse_buffer ),GFP_KERNEL ); -if (!priv->tx_ring) + dma->tx_ring =kcalloc (tx_descs,sizeof (struct altera_dma_private ),GFP_KERNEL ); +if (!dma->tx_ring) goto err_tx_ring; - priv->tx_cons =0 ; - priv->tx_prod =0 ; + dma->tx_cons =0 ; + dma->tx_prod =0 ;/* Init Rx ring */ for (i =0 ; i < rx_descs; i++) { - ret =tse_init_rx_buffer (priv, &priv->rx_ring[i], - priv->rx_dma_buf_sz); + ret =tse_init_rx_buffer (priv, &priv->dma_priv.rx_ring[i], dma->rx_dma_buf_sz);if (ret) goto err_init_rx_buffers; } - priv->rx_cons =0 ; - priv->rx_prod =0 ; + dma->rx_cons =0 ; + dma->rx_prod =0 ;return 0 ; err_init_rx_buffers:while (--i >=0 ) -tse_free_rx_buffer (priv, &priv->rx_ring[i]); -kfree (priv->tx_ring); +tse_free_rx_buffer (priv, &priv->dma_priv.rx_ring[i]); +kfree (dma->tx_ring); err_tx_ring: -kfree (priv->rx_ring); +kfree (dma->rx_ring); err_rx_ring:return ret;}
...
Re: [PATCH 5/5] net: ethernet: altera: rename functions and their prototypes
In reply to [email protected]Hi,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/deepakx-nagaraju-intel-com/net-ethernet-altera-remove-unneeded-assignments/20231213-151600 base: net/main patch link: https://lore.kernel.org/r/20231213071112.18242-6-deepakx.nagaraju%40intel.com patch subject: [PATCH 5/5] net: ethernet: altera: rename functions and their prototypes config: m68k-randconfig-r081-20231218 (https://download.01.org/0day-ci/archive/20231220/[email protected]/config) compiler: m68k-linux-gcc (GCC) 13.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/net/ethernet/altera/altera_tse_main.c:266 alloc_init_skbufs() warn: double check that we're allocating correct size: 24 vs 164
Old smatch warnings:drivers/net/ethernet/altera/altera_tse_main.c:271 alloc_init_skbufs() warn: double check that we're allocating correct size: 24 vs 164 drivers/net/ethernet/altera/altera_tse_main.c:988 tse_open() warn: 'priv->tx_irq' from request_irq() not released on lines: 988.
vim +266 drivers/net/ethernet/altera/altera_tse_main.c
bbd2190ce96d8f Vince Bridgers 2014-03-17 257 static int alloc_init_skbufs(struct altera_tse_private *priv)
bbd2190ce96d8f Vince Bridgers 2014-03-17 258 {
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 259 struct altera_dma_private *dma = &priv->dma_priv;
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 260 unsigned int rx_descs = dma->rx_ring_size;
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 261 unsigned int tx_descs = dma->tx_ring_size;
bbd2190ce96d8f Vince Bridgers 2014-03-17 262 int ret = -ENOMEM;
bbd2190ce96d8f Vince Bridgers 2014-03-17 263 int i;
bbd2190ce96d8f Vince Bridgers 2014-03-17 264
bbd2190ce96d8f Vince Bridgers 2014-03-17 265 /* Create Rx ring buffer */ad6f888f174e6a Nagaraju DeepakX 2023-12-13 @266 dma->rx_ring = kcalloc(rx_descs, sizeof(struct altera_dma_private), GFP_KERNEL);
There is a mismatch here. dma->rx_ring was changed to altera_dma_buffer but the sizeof was changed to altera_dma_private.
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 267 if (!dma->rx_ring)
bbd2190ce96d8f Vince Bridgers 2014-03-17 268 goto err_rx_ring;
bbd2190ce96d8f Vince Bridgers 2014-03-17 269
bbd2190ce96d8f Vince Bridgers 2014-03-17 270 /* Create Tx ring buffer */
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 271 dma->tx_ring = kcalloc(tx_descs, sizeof(struct altera_dma_private), GFP_KERNEL);
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 272 if (!dma->tx_ring)
bbd2190ce96d8f Vince Bridgers 2014-03-17 273 goto err_tx_ring;
bbd2190ce96d8f Vince Bridgers 2014-03-17 274
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 275 dma->tx_cons = 0;
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 276 dma->tx_prod = 0;
bbd2190ce96d8f Vince Bridgers 2014-03-17 277
bbd2190ce96d8f Vince Bridgers 2014-03-17 278 /* Init Rx ring */
bbd2190ce96d8f Vince Bridgers 2014-03-17 279 for (i = 0; i < rx_descs; i++) {
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 280 ret = tse_init_rx_buffer(priv, &priv->dma_priv.rx_ring[i], dma->rx_dma_buf_sz);
bbd2190ce96d8f Vince Bridgers 2014-03-17 281 if (ret)
bbd2190ce96d8f Vince Bridgers 2014-03-17 282 goto err_init_rx_buffers;
bbd2190ce96d8f Vince Bridgers 2014-03-17 283 }
bbd2190ce96d8f Vince Bridgers 2014-03-17 284
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 285 dma->rx_cons = 0;
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 286 dma->rx_prod = 0;
bbd2190ce96d8f Vince Bridgers 2014-03-17 287
bbd2190ce96d8f Vince Bridgers 2014-03-17 288 return 0;
bbd2190ce96d8f Vince Bridgers 2014-03-17 289 err_init_rx_buffers:
bbd2190ce96d8f Vince Bridgers 2014-03-17 290 while (--i >= 0)
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 291 tse_free_rx_buffer(priv, &priv->dma_priv.rx_ring[i]);
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 292 kfree(dma->tx_ring);
bbd2190ce96d8f Vince Bridgers 2014-03-17 293 err_tx_ring:
ad6f888f174e6a Nagaraju DeepakX 2023-12-13 294 kfree(dma->rx_ring);
bbd2190ce96d8f Vince Bridgers 2014-03-17 295 err_rx_ring:
bbd2190ce96d8f Vince Bridgers 2014-03-17 296 return ret;
bbd2190ce96d8f Vince Bridgers 2014-03-17 297 }Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki