Skip to contentSkip to conversation

bgmac: driver for GBit MAC core on BCMA bus

PATCH Superseded Rafał Miłecki 3 participants 4 messages Jan 8, 2013 – Jan 9, 2013

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH v5 1/1 bgmac: driver for GBit MAC core on BCMA bus

BCMA is a Broadcom specific bus with devices AKA cores. All recent BCMA based SoCs have gigabit ethernet provided by the GBit MAC core. This patch adds driver for such a cores registering itself as a netdev. It has been tested on a BCM4706 and BCM4718 chipsets.

In the kernel tree there is already b44 driver which has some common things with bgmac, however there are many differences that has led to the decision or writing a new driver:
1) GBit MAC cores appear on BCMA bus (not SSB as in case of b44)
2) There is 64bit DMA engine which differs from 32bit one
3) There is no CAM (Content Addressable Memory) in GBit MAC
4) We have 4 TX queues on GBit MAC devices (instead of 1)
5) Many registers have different addresses/values
6) RX header flags are also different

The driver in it's state is functional how, however there is of course place for improvements:
1) Supporting more net_device_ops
2) SUpporting more ethtool_ops
3) Unaligned addressing in DMA
4) Writing separated PHY driver

---
V2: fix typos
improve stat_xmit (netif_stop_queue)
change scope of some variables
switch to dev_kfree_skb
change net_dev->stats.rx_dropped
drop "bool tx;" from DMA ring struct
bgmac_open: fail on IRQ request error
use dev<level> for printing (this is great!)
V3: fix strings (long lines)
fix returned values in xmit
some extra info message about PHY addr
V4: stop queue when ring is full
V5: stop queue in case ring is full at xmit start
add *net_dev = bgmac->net_dev helper
use the correct phy_id when R/W phy regs

---
 drivers/bcma/driver_chipcommon_pmu.c        |    3 +-
 drivers/net/ethernet/broadcom/Kconfig       |    9 +
 drivers/net/ethernet/broadcom/Makefile      |    1 +
 drivers/net/ethernet/broadcom/bgmac.c       | 1422 +++++++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bgmac.h       |  456 +++++++++
 include/linux/bcma/bcma_driver_chipcommon.h |    2 +
 6 files changed, 1892 insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bgmac.c
 create mode 100644 drivers/net/ethernet/broadcom/bgmac.h
drivers/bcma/driver_chipcommon_pmu.c +2 -1
index c62c788..932b101 100644
@@ -264,7 +264,7 @@ static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
 }
 
 /* query bus clock frequency for PMU-enabled chipcommon */
-static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
+u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
 {
 	struct bcma_bus *bus = cc->core->bus;
 
@@ -293,6 +293,7 @@ static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
 	}
 	return BCMA_CC_PMU_HT_CLOCK;
 }
+EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock);
 
 /* query cpu clock frequency for PMU-enabled chipcommon */
 u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
drivers/net/ethernet/broadcom/Kconfig +9 -0
index f552673..42c0913 100644
@@ -121,4 +121,13 @@ config BNX2X
 	  To compile this driver as a module, choose M here: the module
 	  will be called bnx2x.  This is recommended.
 
+config BGMAC
+	tristate "BCMA bus GBit core support"
+	depends on BCMA_HOST_SOC && HAS_DMA
+	---help---
+	  This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus.
+	  They can be found on BCM47xx SoCs and provide gigabit ethernet.
+	  In case of using this driver on BCM4706 it's also requires to enable
+	  BCMA_DRIVER_GMAC_CMN to make it work.
+
 endif # NET_VENDOR_BROADCOM
drivers/net/ethernet/broadcom/Makefile +1 -0
index b789605..68efa1a 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_CNIC) += cnic.o
 obj-$(CONFIG_BNX2X) += bnx2x/
 obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
 obj-$(CONFIG_TIGON3) += tg3.o
+obj-$(CONFIG_BGMAC) += bgmac.o
drivers/net/ethernet/broadcom/bgmac.c new file +1422 -0

1,422 lines not on this page · raw message

drivers/net/ethernet/broadcom/bgmac.h new file +456 -0

456 lines not on this page · raw message

include/linux/bcma/bcma_driver_chipcommon.h +2 -0
index 9a0e3fa..ee332fa 100644
@@ -634,4 +634,6 @@ extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc,
 				       u32 offset, u32 mask, u32 set);
 extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
 
+extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
+
 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
Signature · 1 line
1.7.7
#1 lore raw

Hello Rafal,

Quoted 15 lines · Rafał Miłecki

BCMA is a Broadcom specific bus with devices AKA cores. All recent BCMA based SoCs have gigabit ethernet provided by the GBit MAC core. This patch adds driver for such a cores registering itself as a netdev. It has been tested on a BCM4706 and BCM4718 chipsets.

In the kernel tree there is already b44 driver which has some common things with bgmac, however there are many differences that has led to the decision or writing a new driver:
1) GBit MAC cores appear on BCMA bus (not SSB as in case of b44)
2) There is 64bit DMA engine which differs from 32bit one
3) There is no CAM (Content Addressable Memory) in GBit MAC
4) We have 4 TX queues on GBit MAC devices (instead of 1)
5) Many registers have different addresses/values
6) RX header flags are also different

Quoted 6 lines

The driver in it's state is functional how, however there is of course place for improvements:
1) Supporting more net_device_ops
2) SUpporting more ethtool_ops
3) Unaligned addressing in DMA
4) Writing separated PHY driver

It does not seem like 4) would be too hard to do just right now because your PHY functions actually match the semantics of the callbacks you are supposed to implement for a separate PHY driver. Doing this would make you use phylib in the bgmac driver which is a good thing.

I would be glad if you could do this just now, so we make sure this does not get lost.

If David is ok with your v5 patch and wants to merge it just now, I am just as happy with that. --
Florian

author maintainer
#2 lore raw

2013/1/8 Florian Fainelli <[email protected]>:

Quoted 32 lines

Hello Rafal,

Quoted 15 lines · Rafał Miłecki

BCMA is a Broadcom specific bus with devices AKA cores. All recent BCMA based SoCs have gigabit ethernet provided by the GBit MAC core. This patch adds driver for such a cores registering itself as a netdev. It has been tested on a BCM4706 and BCM4718 chipsets.

In the kernel tree there is already b44 driver which has some common things with bgmac, however there are many differences that has led to the decision or writing a new driver:
1) GBit MAC cores appear on BCMA bus (not SSB as in case of b44)
2) There is 64bit DMA engine which differs from 32bit one
3) There is no CAM (Content Addressable Memory) in GBit MAC
4) We have 4 TX queues on GBit MAC devices (instead of 1)
5) Many registers have different addresses/values
6) RX header flags are also different

Quoted 6 lines

The driver in it's state is functional how, however there is of course place for improvements:
1) Supporting more net_device_ops
2) SUpporting more ethtool_ops
3) Unaligned addressing in DMA
4) Writing separated PHY driver

It does not seem like 4) would be too hard to do just right now because your PHY functions actually match the semantics of the callbacks you are supposed to implement for a separate PHY driver. Doing this would make you use phylib in the bgmac driver which is a good thing.

Quoted 5 lines

I would be glad if you could do this just now, so we make sure this does not get lost.

If David is ok with your v5 patch and wants to merge it just now, I am just as happy with that.

Personally I'd like to have it pushed even with limited features, as long as it doesn't go anything really wrong.

It's harder to maintain whole driver as a patch, harder to make a changes, harder to track/review them and somehow discouraging the developer (me). I prefer sending small changes than mini-bomb of 64KB code each time I want to change 5 lines.
You can always find some small feature that could be implemented with a low cost and postpone driver inclusion for weeks/months. I'd like to avoid that.
Apart from that, having driver pushed into some "real" tree makes it possible for other developers to cooperate (see Nathan who sent fixes to OpenWRT).

If you're afraid of forgetting anything from the "TODO" list placed in commit message, we can always create a "TODO" file for the driver. I don't think we really need that though.

Signature · 1 line
Rafał
maintainer
#3 lore raw
In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>
Date: Tue, 8 Jan 2013 07:34:48 +0100

Quoted 15 lines

BCMA is a Broadcom specific bus with devices AKA cores. All recent BCMA based SoCs have gigabit ethernet provided by the GBit MAC core. This patch adds driver for such a cores registering itself as a netdev. It has been tested on a BCM4706 and BCM4718 chipsets.

In the kernel tree there is already b44 driver which has some common things with bgmac, however there are many differences that has led to the decision or writing a new driver:
1) GBit MAC cores appear on BCMA bus (not SSB as in case of b44)
2) There is 64bit DMA engine which differs from 32bit one
3) There is no CAM (Content Addressable Memory) in GBit MAC
4) We have 4 TX queues on GBit MAC devices (instead of 1)
5) Many registers have different addresses/values
6) RX header flags are also different

Quoted 8 lines

The driver in it's state is functional how, however there is of course place for improvements:
1) Supporting more net_device_ops
2) SUpporting more ethtool_ops
3) Unaligned addressing in DMA
4) Writing separated PHY driver

This patch doesn't apply to the net-next tree, please re-spin.