Skip to contentSkip to conversation

Blackfin: on-chip ethernet MAC controller driver

PATCH In review Wu, Bryan 5 participants 6 messages Mar 1, 2007 – Mar 2, 2007

Subsystems (2)
lore
Share & tools
lore

Wu, Bryan

author
#0 lore raw

PATCH 3/5 Blackfin: on-chip ethernet MAC controller driver

Hi folks,

Here is the blackfin on-chip ethernet MAC controller driver for Linux.

It's name is blackfin-driver-net-stamp537.patch

[PATCH] Blackfin: on-chip ethernet MAC controller driver

This patch implements the driver necessary use the Analog Devices Blackfin processor's on-chip ethernet MAC controller.

---

 drivers/net/Kconfig    |   44 ++
 drivers/net/Makefile   |    1
 drivers/net/bfin_mac.c |  988 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/bfin_mac.h |  146 +++++++++
 4 files changed, 1179 insertions(+)
drivers/net/Kconfig +44 -0
Index: linux-2.6/drivers/net/Kconfig
===================================================================
@@ -836,6 +836,50 @@
 	  module, say M here and read <file:Documentation/modules.txt> as well
 	  as <file:Documentation/networking/net-modules.txt>.
 
+config BFIN_MAC
+	tristate "Blackfin 536/537 on-chip mac support"
+	depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
+	select CRC32
+	select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+	help
+	  This is the driver for blackfin on-chip mac device. Say Y if you want it
+	  compiled into the kernel. This driver is also available as a module
+	  ( = code which can be inserted in and removed from the running kernel
+	  whenever you want). The module will be called bfin_mac.
+
+config BFIN_MAC_USE_L1
+	bool "Use L1 memory for rx/tx packets"
+	depends on BFIN_MAC && BF537
+	default y
+	help
+	  To get maximum network performace, you should use L1 memory as rx/tx buffers.
+	  Say N here if you want to reserve L1 memory for other uses.
+
+config BFIN_TX_DESC_NUM
+	int "Number of transmit buffer packets"
+	depends on BFIN_MAC
+	range 6 10 if BFIN_MAC_USE_L1
+	range 10 100
+	default "10"
+	help
+	  Set the number of buffer packets used in driver.
+
+config BFIN_RX_DESC_NUM
+	int "Number of receive buffer packets"
+	depends on BFIN_MAC
+	range 20 100 if BFIN_MAC_USE_L1
+	range 20 800
+	default "20"
+	help
+	  Set the number of buffer packets used in driver.
+
+config BFIN_MAC_RMII
+	bool "RMII PHY Interface (EXPERIMENTAL)"
+	depends on BFIN_MAC && EXPERIMENTAL
+	default n
+	help
+	  Use Reduced PHY MII Interface
+
 config SMC9194
 	tristate "SMC 9194 support"
 	depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN)
drivers/net/Makefile +1 -0
Index: linux-2.6/drivers/net/Makefile
===================================================================
@@ -195,6 +195,7 @@
 obj-$(CONFIG_MYRI10GE) += myri10ge/
 obj-$(CONFIG_SMC91X) += smc91x.o
 obj-$(CONFIG_SMC911X) += smc911x.o
+obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
 obj-$(CONFIG_DM9000) += dm9000.o
 obj-$(CONFIG_FEC_8XX) += fec_8xx/
 obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o
drivers/net/bfin_mac.c new file +988 -0

988 lines not on this page · raw message

drivers/net/bfin_mac.h new file +146 -0

146 lines not on this page · raw message

---

Thanks
-Bryan

#1 lore raw
Quoted 13 lines · Bryan

Hi folks,

Here is the blackfin on-chip ethernet MAC controller driver for Linux.

It's name is blackfin-driver-net-stamp537.patch

[PATCH] Blackfin: on-chip ethernet MAC controller driver

This patch implements the driver necessary use the Analog Devices Blackfin processor's on-chip ethernet MAC controller.

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+extern void get_bf537_ether_addr(char *addr);

Please don't put extern declarations in .c code. Put them in a header file which is included by the file which provides the definition and by all files which refer to the symbol.

Please review the entire blackfin patchset for more occurrences of this mistake.

Quoted 19 lines
drivers/net/bfin_mac.c new file +19 -0
+static int bf537mac_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct bf537mac_local *lp = netdev_priv(dev);
+	unsigned int data;
+
+	current_tx_ptr->skb = skb;
+	// Is skb->data always 16-bit aligned? Do we need to memcpy((char *)(tail->packet + 2),skb->data,len)?
+	if ((((unsigned int)(skb->data)) & 0x02) == 2) {
+		//move skb->data to current_tx_ptr payload
+		data = (unsigned int)(skb->data) - 2;
+		*((unsigned short *)data) = (unsigned short)(skb->len);
+		current_tx_ptr->desc_a.start_addr = (unsigned long)data;
+		blackfin_dcache_flush_range(data, (data + (skb->len)) + 2);	//this is important!
+
+	} else {
+		*((unsigned short *)(current_tx_ptr->packet)) =
+		    (unsigned short)(skb->len);
+		memcpy((char *)(current_tx_ptr->packet + 2), skb->data,
+		       (skb->len));

drivers/net/bfin_mac.c line 539

Quoted 10 lines
drivers/net/bfin_mac.c new file +10 -0
+		current_tx_ptr->desc_a.start_addr =
+		    (unsigned long)current_tx_ptr->packet;
+		if (current_tx_ptr->status.status_word != 0)
+			current_tx_ptr->status.status_word = 0;
+		blackfin_dcache_flush_range((unsigned int)current_tx_ptr->
+					    packet,
+					    (unsigned int)(current_tx_ptr->
+							   packet + skb->len) +
+					    2);
+	}

hm, I'd have thought that networking provided a way of avoiding that memcpy, but it has been too long..

Quoted 19 lines
drivers/net/bfin_mac.c new file +19 -0
+	current_tx_ptr->desc_a.config.b_DMA_EN = 1;	//enable this packet's dma
+
+	if (bfin_read_DMA2_IRQ_STATUS() & 0x08) {	//tx dma is running, just return
+		goto out;
+	} else {		//tx dma is not running
+		bfin_write_DMA2_NEXT_DESC_PTR(&(current_tx_ptr->desc_a));
+		bfin_write_DMA2_CONFIG(*((unsigned short *)(&(current_tx_ptr->desc_a.config))));	// dma enabled, read from memory, size is 6
+		// Turn on the EMAC tx
+		bfin_write_EMAC_OPMODE(bfin_read_EMAC_OPMODE() | TE);
+	}
+
+      out:
+	adjust_tx_list();
+	current_tx_ptr = current_tx_ptr->next;
+	dev->trans_start = jiffies;
+	lp->stats.tx_packets++;
+	lp->stats.tx_bytes += (skb->len);
+	return 0;
+}
#2 lore raw
In reply to Wu, Bryan
Quoted 55 lines · Bryan

Hi folks,

Here is the blackfin on-chip ethernet MAC controller driver for Linux.

It's name is blackfin-driver-net-stamp537.patch

[PATCH] Blackfin: on-chip ethernet MAC controller driver

This patch implements the driver necessary use the Analog Devices Blackfin processor's on-chip ethernet MAC controller.

---

 drivers/net/Kconfig    |   44 ++
 drivers/net/Makefile   |    1
 drivers/net/bfin_mac.c |  988 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/bfin_mac.h |  146 +++++++++
 4 files changed, 1179 insertions(+)

Index: linux-2.6/drivers/net/Kconfig
===================================================================

drivers/net/Kconfig +27 -0
@@ -836,6 +836,50 @@
 	  module, say M here and read <file:Documentation/modules.txt> as well
 	  as <file:Documentation/networking/net-modules.txt>.
 
+config BFIN_MAC
+	tristate "Blackfin 536/537 on-chip mac support"
+	depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
+	select CRC32
+	select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+	help
+	  This is the driver for blackfin on-chip mac device. Say Y if you want it
+	  compiled into the kernel. This driver is also available as a module
+	  ( = code which can be inserted in and removed from the running kernel
+	  whenever you want). The module will be called bfin_mac.
+
+config BFIN_MAC_USE_L1
+	bool "Use L1 memory for rx/tx packets"
+	depends on BFIN_MAC && BF537
+	default y
+	help
+	  To get maximum network performace, you should use L1 memory as rx/tx buffers.
+	  Say N here if you want to reserve L1 memory for other uses.
+
+config BFIN_TX_DESC_NUM
+	int "Number of transmit buffer packets"
+	depends on BFIN_MAC
+	range 6 10 if BFIN_MAC_USE_L1
+	range 10 100
+	default "10"
+	help
+	  Set the number of buffer packets used in driver.

drivers/net/Kconfig line 875

Quoted 10 lines
drivers/net/Kconfig +9 -0
+
+config BFIN_RX_DESC_NUM
+	int "Number of receive buffer packets"
+	depends on BFIN_MAC
+	range 20 100 if BFIN_MAC_USE_L1
+	range 20 800
+	default "20"
+	help
+	  Set the number of buffer packets used in driver
 

The regular practice is to put these in a device include file, and not make them kernel configurable. Why would you want to make it tuneable at compile time?

Quoted 112 lines
drivers/net/Kconfig +8 -0
+
+config BFIN_MAC_RMII
+	bool "RMII PHY Interface (EXPERIMENTAL)"
+	depends on BFIN_MAC && EXPERIMENTAL
+	default n
+	help
+	  Use Reduced PHY MII Interface
+
 config SMC9194
 	tristate "SMC 9194 support"

depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN)
Index: linux-2.6/drivers/net/Makefile
===================================================================

drivers/net/Makefile +1 -0
@@ -195,6 +195,7 @@
 obj-$(CONFIG_MYRI10GE) += myri10ge/
 obj-$(CONFIG_SMC91X) += smc91x.o
 obj-$(CONFIG_SMC911X) += smc911x.o
+obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
 obj-$(CONFIG_DM9000) += dm9000.o
 obj-$(CONFIG_FEC_8XX) += fec_8xx/
 obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o

Index: linux-2.6/drivers/net/bfin_mac.c
===================================================================

drivers/net/bfin_mac.c new file +83 -0
@@ -0,0 +1,988 @@
+/*
+ * File:         drivers/net/bfin_mac.c
+ * Based on:
+ * Author:       Luke Yang <[email protected]>
+ *
+ * Created:
+ * Description:
+ *
+ * Rev:          $Id: bfin_mac.c,v 1.60 2006/12/16 11:23:56 hennerich Exp $
+ *
+ * Modified:
+ *               Copyright 2004-2006 Analog Devices Inc.
+ *
+ * Bugs:         Enter bugs at http://blackfin.uclinux.org/
+ *
+ * This program is free software ;  you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation ;  either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY ;  without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program ;  see the file COPYING.
+ * If not, write to the Free Software Foundation,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/crc32.h>
+#include <linux/device.h>
+#include <linux/spinlock.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+
+#include <linux/platform_device.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/dma.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/irq.h>
+#include <asm/blackfin.h>
+#include <asm/delay.h>
+
+#include "bfin_mac.h"
+
+#define CARDNAME "bfin_mac"
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Luke Yang");
+MODULE_DESCRIPTION("Blackfin MAC Driver");
+
+#if defined(CONFIG_BFIN_MAC_USE_L1)
+# define bfin_mac_alloc(dma_handle, size)  l1_data_sram_zalloc(size)
+# define bfin_mac_free(dma_handle, ptr)    l1_data_sram_free(ptr)
+#else
+# define bfin_mac_alloc(dma_handle, size)  dma_alloc_coherent(NULL, size, dma_handle, GFP_DMA)
+# define bfin_mac_free(dma_handle, ptr)    dma_free_coherent(NULL, sizeof(*ptr), ptr, dma_handle)
+#endif
+
+#define PKT_BUF_SZ 1580
+
+static void desc_list_free(void);

drivers/net/bfin_mac.c line 93

Quoted 10 lines
drivers/net/bfin_mac.c new file +10 -0
+
+/* pointers to maintain transmit list */
+struct net_dma_desc_tx *tx_list_head;
+struct net_dma_desc_tx *tx_list_tail;
+struct net_dma_desc_rx *rx_list_head;
+struct net_dma_desc_rx *rx_list_tail;
+struct net_dma_desc_rx *current_rx_ptr;
+struct net_dma_desc_tx *current_tx_ptr;
+struct net_dma_desc_tx *tx_desc;
+struct net_dma_desc_rx *rx_desc;

These should all be static

Quoted 32 lines
drivers/net/bfin_mac.c new file +31 -0
+
+extern void get_bf537_ether_addr(char *addr);
+
+static int desc_list_init(void)
+{
+	struct net_dma_desc_tx *tmp_desc_tx;
+	struct net_dma_desc_rx *tmp_desc_rx;
+	int i;
+	struct sk_buff *new_skb;
+#if !defined(CONFIG_BFIN_MAC_USE_L1)
+	dma_addr_t dma_handle;
+#endif
+
+	tx_desc =
+	    bfin_mac_alloc(&dma_handle,
+			   sizeof(struct net_dma_desc_tx) *
+			   CONFIG_BFIN_TX_DESC_NUM);
+	if (tx_desc == NULL)
+		goto init_error;
+
+	rx_desc =
+	    bfin_mac_alloc(&dma_handle,
+			   sizeof(struct net_dma_desc_rx) *
+			   CONFIG_BFIN_RX_DESC_NUM);
+	if (rx_desc == NULL)
+		goto init_error;
+
+	/* init tx_list */
+	for (i = 0; i < CONFIG_BFIN_TX_DESC_NUM; i++) {
+
+		tmp_desc_tx = tx_desc + i;

drivers/net/bfin_mac.c line 134

Quoted 10 lines
drivers/net/bfin_mac.c new file +10 -0
+
+		if (i == 0) {
+			tx_list_head = tmp_desc_tx;
+			tx_list_tail = tmp_desc_tx;
+		}
+
+		tmp_desc_tx->desc_a.start_addr =
+		    (unsigned long)tmp_desc_tx->packet;
+		tmp_desc_tx->desc_a.x_count = 0;
+		tmp_desc_tx->desc_a.config.b_DMA_EN = 0;	//disabled

Coding Style for Linux kernel is to *not* use C++ style comments (ie. //)

Quoted 119 lines
drivers/net/bfin_mac.c new file +119 -0
+		tmp_desc_tx->desc_a.config.b_WNR = 0;	//read from memory
+		tmp_desc_tx->desc_a.config.b_WDSIZE = 2;	//wordsize is 32 bits
+		tmp_desc_tx->desc_a.config.b_NDSIZE = 6;	//6 half words is desc size.
+		tmp_desc_tx->desc_a.config.b_FLOW = 7;	//large desc flow
+		tmp_desc_tx->desc_a.next_dma_desc = &(tmp_desc_tx->desc_b);
+
+		tmp_desc_tx->desc_b.start_addr =
+		    (unsigned long)(&(tmp_desc_tx->status));
+		tmp_desc_tx->desc_b.x_count = 0;
+		tmp_desc_tx->desc_b.config.b_DMA_EN = 1;	//enabled
+		tmp_desc_tx->desc_b.config.b_WNR = 1;	//write to memory
+		tmp_desc_tx->desc_b.config.b_WDSIZE = 2;	//wordsize is 32 bits
+		tmp_desc_tx->desc_b.config.b_DI_EN = 0;	//disable interrupt
+		tmp_desc_tx->desc_b.config.b_NDSIZE = 6;
+		tmp_desc_tx->desc_b.config.b_FLOW = 7;	//stop mode
+		tmp_desc_tx->skb = NULL;
+		tx_list_tail->desc_b.next_dma_desc = &(tmp_desc_tx->desc_a);
+		tx_list_tail->next = tmp_desc_tx;
+
+		tx_list_tail = tmp_desc_tx;
+	}
+	tx_list_tail->next = tx_list_head;	/* tx_list is a circle */
+	tx_list_tail->desc_b.next_dma_desc = &(tx_list_head->desc_a);
+	current_tx_ptr = tx_list_head;
+
+	/* init rx_list */
+	for (i = 0; i < CONFIG_BFIN_RX_DESC_NUM; i++) {
+
+		tmp_desc_rx = rx_desc + i;
+
+		if (i == 0) {
+			rx_list_head = tmp_desc_rx;
+			rx_list_tail = tmp_desc_rx;
+		}
+
+		/* allocat a new skb for next time receive */
+		new_skb = dev_alloc_skb(PKT_BUF_SZ + 2);
+		if (!new_skb) {
+			printk(KERN_NOTICE CARDNAME
+			       ": init: low on mem - packet dropped\n");
+			goto init_error;
+		}
+		skb_reserve(new_skb, 2);
+		tmp_desc_rx->skb = new_skb;
+		/* since RXDWA is enabled */
+		tmp_desc_rx->desc_a.start_addr =
+		    (unsigned long)new_skb->data - 2;
+		tmp_desc_rx->desc_a.x_count = 0;
+		tmp_desc_rx->desc_a.config.b_DMA_EN = 1;	//enabled
+		tmp_desc_rx->desc_a.config.b_WNR = 1;	//Write to memory
+		tmp_desc_rx->desc_a.config.b_WDSIZE = 2;	//wordsize is 32 bits
+		tmp_desc_rx->desc_a.config.b_NDSIZE = 6;	//6 half words is desc size.
+		tmp_desc_rx->desc_a.config.b_FLOW = 7;	//large desc flow
+		tmp_desc_rx->desc_a.next_dma_desc = &(tmp_desc_rx->desc_b);
+
+		tmp_desc_rx->desc_b.start_addr =
+		    (unsigned long)(&(tmp_desc_rx->status));
+		tmp_desc_rx->desc_b.x_count = 0;
+		tmp_desc_rx->desc_b.config.b_DMA_EN = 1;	//enabled
+		tmp_desc_rx->desc_b.config.b_WNR = 1;	//Write to memory
+		tmp_desc_rx->desc_b.config.b_WDSIZE = 2;	//wordsize is 32 bits
+		tmp_desc_rx->desc_b.config.b_NDSIZE = 6;
+		tmp_desc_rx->desc_b.config.b_DI_EN = 1;	//enable interrupt
+		tmp_desc_rx->desc_b.config.b_FLOW = 7;	//large mode
+		rx_list_tail->desc_b.next_dma_desc = &(tmp_desc_rx->desc_a);
+
+		rx_list_tail->next = tmp_desc_rx;
+		rx_list_tail = tmp_desc_rx;
+	}
+	rx_list_tail->next = rx_list_head;	/* rx_list is a circle */
+	rx_list_tail->desc_b.next_dma_desc = &(rx_list_head->desc_a);
+	current_rx_ptr = rx_list_head;
+
+	return 0;
+
+      init_error:
+	desc_list_free();
+	printk(KERN_ERR CARDNAME ": kmalloc failed\n");
+	return -ENOMEM;
+}
+
+static void desc_list_free(void)
+{
+	struct net_dma_desc_rx *tmp_desc_rx;
+	struct net_dma_desc_tx *tmp_desc_tx;
+	int i;
+#if !defined(CONFIG_BFIN_MAC_USE_L1)
+	dma_addr_t dma_handle = 0;
+#endif
+
+	if (tx_desc != NULL) {
+		tmp_desc_tx = tx_list_head;
+		for (i = 0; i < CONFIG_BFIN_TX_DESC_NUM; i++) {
+			if (tmp_desc_tx != NULL) {
+				if (tmp_desc_tx->skb) {
+					dev_kfree_skb(tmp_desc_tx->skb);
+					tmp_desc_tx->skb = NULL;
+				}
+
+			}
+			tmp_desc_tx = tmp_desc_tx->next;
+		}
+		bfin_mac_free(dma_handle, tx_desc);
+	}
+
+	if (rx_desc != NULL) {
+		tmp_desc_rx = rx_list_head;
+		for (i = 0; i < CONFIG_BFIN_RX_DESC_NUM; i++) {
+			if (tmp_desc_rx != NULL) {
+				if (tmp_desc_rx->skb) {
+					dev_kfree_skb(tmp_desc_rx->skb);
+					tmp_desc_rx->skb = NULL;
+				}
+			}
+			tmp_desc_rx = tmp_desc_rx->next;
+		}
+		bfin_mac_free(dma_handle, rx_desc);
+	}
+}

drivers/net/bfin_mac.c line 264

Quoted 10 lines
drivers/net/bfin_mac.c new file +10 -0
+
+/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
+
+//
+//Set FER regs to MUX in Ethernet pins
+//
+
+static void SetupPinMux(void)
+{
+	

Please do not use mixed case for function or structure member names (see Coding Style)

#3 lore raw
Quoted 32 lines · Stephen Hemminger
Quoted 31 lines · Bryan
drivers/net/Kconfig +31 -0
+config BFIN_MAC
+     tristate "Blackfin 536/537 on-chip mac support"
+     depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
+     select CRC32
+     select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+     help
+       This is the driver for blackfin on-chip mac device. Say Y if you want it
+       compiled into the kernel. This driver is also available as a module
+       ( = code which can be inserted in and removed from the running kernel
+       whenever you want). The module will be called bfin_mac.
+
+config BFIN_MAC_USE_L1
+     bool "Use L1 memory for rx/tx packets"
+     depends on BFIN_MAC && BF537
+     default y
+     help
+       To get maximum network performace, you should use L1 memory as rx/tx buffers.
+       Say N here if you want to reserve L1 memory for other uses.
+
+config BFIN_TX_DESC_NUM
+     int "Number of transmit buffer packets"
+     depends on BFIN_MAC
+     range 6 10 if BFIN_MAC_USE_L1
+     range 10 100
+     default "10"
+     help
+       Set the number of buffer packets used in driver.
+
+config BFIN_RX_DESC_NUM
+     int "Number of receive buffer packets"
+     depends on BFIN_MAC
Quoted 8 lines

drivers/net/Kconfig

Quoted 6 lines
drivers/net/Kconfig +5 -0
+     range 20 100 if BFIN_MAC_USE_L1
+     range 20 800
+     default "20"
+     help
+       Set the number of buffer packets used in driver

The regular practice is to put these in a device include file, and not make them kernel configurable.

we're working on moving some of this stuff into the board files rather than Kconfig

Quoted 1 line

Why would you want to make it tuneable at compile time?

because it was easier to implement and deploy the first time around ;) -mike

#4 lore raw
In reply to Stephen Hemminger

On Thu 1 Mar 2007 10:52, Stephen Hemminger pondered:

Quoted 45 lines
Quoted 44 lines · Bryan

Hi folks,

Here is the blackfin on-chip ethernet MAC controller driver for Linux.

Index: linux-2.6/drivers/net/Kconfig
===================================================================
--- linux-2.6.orig/drivers/net/Kconfig 2007-03-01 11:39:14.000000000
+0800 +++ linux-2.6/drivers/net/Kconfig 2007-03-01 11:39:19.000000000
+0800 @@ -836,6 +836,50 @@

drivers/net/Kconfig +7 -0
 	  module, say M here and read <file:Documentation/modules.txt> as well
 	  as <file:Documentation/networking/net-modules.txt>.
 
+config BFIN_MAC
+	tristate "Blackfin 536/537 on-chip mac support"
+	depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
+	select CRC32
+	select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+	help
+	  This is the driver for blackfin on-chip mac device. Say Y if you want

it + compiled into the kernel. This driver is also available as a
module + ( = code which can be inserted in and removed from the running
kernel + whenever you want). The module will be called bfin_mac.

drivers/net/Kconfig +7 -0
+
+config BFIN_MAC_USE_L1
+	bool "Use L1 memory for rx/tx packets"
+	depends on BFIN_MAC && BF537
+	default y
+	help
+	  To get maximum network performace, you should use L1 memory as rx/tx

buffers. + Say N here if you want to reserve L1 memory for other uses.

drivers/net/Kconfig +14 -0
+
+config BFIN_TX_DESC_NUM
+	int "Number of transmit buffer packets"
+	depends on BFIN_MAC
+	range 6 10 if BFIN_MAC_USE_L1
+	range 10 100
+	default "10"
+	help
+	  Set the number of buffer packets used in driver.
+
+config BFIN_RX_DESC_NUM
+	int "Number of receive buffer packets"
+	depends on BFIN_MAC
+	range 20 100 if BFIN_MAC_USE_L1
Quoted 8 lines

drivers/net/Kconfig

Quoted 4 lines
drivers/net/Kconfig +4 -0
+	range 20 800
+	default "20"
+	help
+	  Set the number of buffer packets used in driver

The regular practice is to put these in a device include file, and not make them kernel configurable.
Why would you want to make it tuneable at compile time?

It is to attempt to make it easier for our end users to configure&use.

Most people who use it, want to make some tweaks to the configuration based on their embedded platform. Rather than forcing everyone to make changes to a .c or .h file, we let them manage it in the .config (which is platforms specific anyway).

-Robin

author
#5 lore raw
In reply to Stephen Hemminger
Quoted 5 lines · Stephen Hemminger

Please do not use mixed case for function or structure member names (see
Coding Style)

Here is the updated version of this driver.
a) Change to follow kernel coding style
b) rename some functions and structures
c) change '//' to '/* */'
d) use pr_debug()

[PATCH] Blackfin: on-chip ethernet MAC controller driver

This patch implements the driver necessary use the Analog Devices Blackfin processor's on-chip ethernet MAC controller.

---

 drivers/net/Kconfig    |   44 ++
 drivers/net/Makefile   |    1
 drivers/net/bfin_mac.c |  981 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/bfin_mac.h |  147 +++++++++
 4 files changed, 1173 insertions(+)
drivers/net/Kconfig +44 -0
Index: linux-2.6/drivers/net/Kconfig
===================================================================
@@ -836,6 +836,50 @@
 	  module, say M here and read <file:Documentation/modules.txt> as well
 	  as <file:Documentation/networking/net-modules.txt>.
 
+config BFIN_MAC
+	tristate "Blackfin 536/537 on-chip mac support"
+	depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
+	select CRC32
+	select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+	help
+	  This is the driver for blackfin on-chip mac device. Say Y if you want it
+	  compiled into the kernel. This driver is also available as a module
+	  ( = code which can be inserted in and removed from the running kernel
+	  whenever you want). The module will be called bfin_mac.
+
+config BFIN_MAC_USE_L1
+	bool "Use L1 memory for rx/tx packets"
+	depends on BFIN_MAC && BF537
+	default y
+	help
+	  To get maximum network performace, you should use L1 memory as rx/tx buffers.
+	  Say N here if you want to reserve L1 memory for other uses.
+
+config BFIN_TX_DESC_NUM
+	int "Number of transmit buffer packets"
+	depends on BFIN_MAC
+	range 6 10 if BFIN_MAC_USE_L1
+	range 10 100
+	default "10"
+	help
+	  Set the number of buffer packets used in driver.
+
+config BFIN_RX_DESC_NUM
+	int "Number of receive buffer packets"
+	depends on BFIN_MAC
+	range 20 100 if BFIN_MAC_USE_L1
+	range 20 800
+	default "20"
+	help
+	  Set the number of buffer packets used in driver.
+
+config BFIN_MAC_RMII
+	bool "RMII PHY Interface (EXPERIMENTAL)"
+	depends on BFIN_MAC && EXPERIMENTAL
+	default n
+	help
+	  Use Reduced PHY MII Interface
+
 config SMC9194
 	tristate "SMC 9194 support"
 	depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN)
drivers/net/Makefile +1 -0
Index: linux-2.6/drivers/net/Makefile
===================================================================
@@ -195,6 +195,7 @@
 obj-$(CONFIG_MYRI10GE) += myri10ge/
 obj-$(CONFIG_SMC91X) += smc91x.o
 obj-$(CONFIG_SMC911X) += smc911x.o
+obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
 obj-$(CONFIG_DM9000) += dm9000.o
 obj-$(CONFIG_FEC_8XX) += fec_8xx/
 obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o
drivers/net/bfin_mac.c new file +981 -0

981 lines not on this page · raw message

drivers/net/bfin_mac.h new file +147 -0

147 lines not on this page · raw message

_

Thanks
-Bryan