FDDI: DEC FDDIcontroller 700 TURBOchannel card support
Subsystems (5)
PATCH RESEND 2/2 FDDI: DEC FDDIcontroller 700 TURBOchannel card support
This adds support for the DEC FDDIcontroller 700 (DEFZA), DEC's first-generation FDDI network interface adapter, made for TURBOchannel and based on a discrete version of what eventually became Motorola's widely used CAMEL chipset. The CAMEL chipset is present for example in the DEC FDDIcontroller TURBOchannel, EISA and PCI adapters (DEFTA/DEFEA/DEFPA) that we support with the defxx driver, however the host bus interface logic and the firmware API are different in the DEFZA and hence a separate driver is required.
There isn't much to say about the driver except that it works, but there is one peculiarity to mention. The adapter implements two Tx/Rx queue pairs. Of these one pair is used by hardware to exchange frames with the ring. The other pair is used for SMT frames only, any SMT frame received by hardware on the Rx queue must be queued back by the driver to the SMT Rx queue for the firmware to process. Likewise the SMT Tx queue presents the driver with SMT frames produced by the firmware that must be queued back to the Tx queue for hardware to put on the ring. This solution was chosen because the designers ran out of PCB space and could not squeeze in more logic to handle this SMT frame traffic without the need to involve the driver as with the later DEFTA/DEFEA/DEFPA adapters.
For this reason the driver has frames in the transmit path that it wants to present to network taps (e.g. `tcpdump') but not the normal receive queue. This in turn requires that ptype_all and dev_queue_xmit_nit symbols are exported.
Finally the driver does some Frame Control byte decoding so to avoid magic numbers some macros are added to <linux/if_fddi.h>.
---
Dave,
Please apply. I hope the way I hooked to ptype_all anddev_queue_xmit_nit is fine; let me know if you prefer to use EXPORT_SYMBOL_GPL instead.
This driver could benefit from some improvement, in particular the
interrupt handler should be split and use a thread rather than doing all the stuff in the hardirq, but let's not make better the enemy of good. I've been sitting on this driver for too long already.
There are some warnings with this driver and checkpatch.pl; I consider
them all noise and deliberately ignored, but please let me know if you'd rather see any of them silenced.
Thanks,
Maciej
linux-defza-1.1.3.patch
Documentation/networking/00-INDEX +2 -0
@@ -58,6 +58,8 @@ de4x5.txt - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver decnet.txt - info on using the DECnet networking layer in Linux. +defza.txt + - the DEC FDDIcontroller 700 (DEFZA-xx) TURBOchannel FDDI driver dl2k.txt - README for D-Link DL2000-based Gigabit Ethernet Adapters (dl2k.ko). dm9000.txt
Documentation/networking/defza.txt new file +53 -0
53 lines not on this page · raw message
MAINTAINERS +5 -0
@@ -2697,6 +2697,11 @@ M: "Maciej W. Rozycki" <macro@linux-mips S: Maintained F: drivers/net/fddi/defxx.* +DEFZA FDDI NETWORK DRIVER +M: "Maciej W. Rozycki" <[email protected]> +S: Maintained +F: drivers/net/fddi/defza.* + DELL LAPTOP DRIVER M: Matthew Garrett <[email protected]> L: [email protected]
drivers/net/fddi/Kconfig +11 -0
@@ -15,6 +15,17 @@ config FDDI if FDDI +config DEFZA + tristate "DEC FDDIcontroller 700/700C (DEFZA-xx) support" + depends on FDDI && TC + ---help--- + This is support for the DEC FDDIcontroller 700 (DEFZA-AA, fiber) + and 700C (DEFZA-CA, copper) TURBOchannel network cards which can + connect you to a local FDDI network. + + To compile this driver as a module, choose M here: the module + will be called defza. If unsure, say N. + config DEFXX tristate "Digital DEFTA/DEFEA/DEFPA adapter support" depends on FDDI && (PCI || EISA || TC)
drivers/net/fddi/Makefile +1 -0
@@ -3,4 +3,5 @@ # obj-$(CONFIG_DEFXX) += defxx.o +obj-$(CONFIG_DEFZA) += defza.o obj-$(CONFIG_SKFP) += skfp/
drivers/net/fddi/defza.c new file +1639 -0
1,639 lines not on this page · raw message
drivers/net/fddi/defza.h new file +764 -0
764 lines not on this page · raw message
include/linux/netdevice.h +2 -0
@@ -1887,6 +1887,7 @@ netdev_notifier_info_to_dev(const structint call_netdevice_notifiers (unsigned long val,struct net_device *dev); +extern struct list_head ptype_all;/* Taps */ extern rwlock_t dev_base_lock;/* Device list lock */ #define for_each_netdev (net, d) \
@@ -2631,6 +2632,7 @@ int dev_set_mac_address(struct net_devicint dev_change_carrier (struct net_device *,bool new_carrier);int dev_get_phys_port_id (struct net_device *dev,struct netdev_phys_port_id *ppid); +void dev_queue_xmit_nit (struct sk_buff *skb,struct net_device *dev);int dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev,struct netdev_queue *txq);int __dev_forward_skb (struct net_device *dev,struct sk_buff *skb);
include/uapi/linux/if_fddi.h +18 -3
@@ -5,9 +5,10 @@* * Global definitions for the ANSI FDDI interface. * -* Version: @(#)if_fddi.h 1.0.2 Sep 29 2004 +* Version: @(#)if_fddi.h 1.0.3 Apr 5 2014 * -* Author: Lawrence V. Stefani, <[email protected]> +* Author: Lawrence V. Stefani, <[email protected]> +* Maintainer: Maciej W. Rozycki, <[email protected]> * * if_fddi.h is based on previous if_ether.h and if_tr.h work by * Fred N. van Kempen, <[email protected]>
@@ -44,7 +45,21 @@#define FDDI_K_OUI_LEN 3/* Octets in OUI in 802.2 SNAP header */ -/* Define FDDI Frame Control (FC) Byte values */ +/* Define FDDI Frame Control (FC) Byte masks */ +#define FDDI_FC_K_CLASS_MASK 0x80/* class bit */ +#define FDDI_FC_K_CLASS_SYNC 0x80 +#define FDDI_FC_K_CLASS_ASYNC 0x00 +#define FDDI_FC_K_ALEN_MASK 0x40/* address length bit */ +#define FDDI_FC_K_ALEN_48 0x40 +#define FDDI_FC_K_ALEN_16 0x00 +#define FDDI_FC_K_FORMAT_MASK 0x30/* format bits */ +#define FDDI_FC_K_FORMAT_FUTURE 0x30 +#define FDDI_FC_K_FORMAT_IMPLEMENTOR 0x20 +#define FDDI_FC_K_FORMAT_LLC 0x10 +#define FDDI_FC_K_FORMAT_MANAGEMENT 0x00 +#define FDDI_FC_K_CONTROL_MASK 0x0f/* control bits */ + +/* Define FDDI Frame Control (FC) Byte specific values */ #define FDDI_FC_K_VOID 0x00#define FDDI_FC_K_NON_RESTRICTED_TOKEN 0x80#define FDDI_FC_K_RESTRICTED_TOKEN 0xC0
net/core/dev.c +4 -2
@@ -144,7 +144,8 @@static DEFINE_SPINLOCK (ptype_lock);static DEFINE_SPINLOCK (offload_lock);struct list_head ptype_base[PTYPE_HASH_SIZE ]__read_mostly ; -struct list_head ptype_all__read_mostly ;/* Taps */ +struct list_head ptype_all__read_mostly ;/* Taps */ +EXPORT_SYMBOL (ptype_all);static struct list_head offload_base__read_mostly ;static int netif_rx_internal (struct sk_buff *skb);
@@ -1736,7 +1737,7 @@ static inline bool skb_loop_sk(struct pa* taps currently in use. */ -static void dev_queue_xmit_nit (struct sk_buff *skb,struct net_device *dev) +void dev_queue_xmit_nit (struct sk_buff *skb,struct net_device *dev) {struct packet_type *ptype;struct sk_buff *skb2 =NULL ;
@@ -1784,6 +1785,7 @@ static void dev_queue_xmit_nit(struct sk pt_prev->func (skb2, skb->dev, pt_prev, skb->dev);rcu_read_unlock (); } +EXPORT_SYMBOL (dev_queue_xmit_nit);/** * netif_setup_tc - Handle tc mappings on real_num_tx_queues change
David Miller
maintainerFrom: "Maciej W. Rozycki" <[email protected]>
Date: Fri, 25 Apr 2014 10:35:15 +0100 (BST)
drivers/net/fddi/defza.c line 222
Quoted 7 lines
drivers/net/fddi/defza.c new file +7
-0+/* Reset the board. */ +wmb (); +writew (FZA_RESET_INIT , &fp->regs->reset); +iob (); +readw (&fp->regs->reset);/* Read it back for a small delay. */ +iob (); +writew (FZA_RESET_CLR , &fp->regs->reset);
Using memory barriers around MMIO operations makes zero sense.
wmb() and friends order physical memory operations, and are only to be used when the cpu must be synchronized with some other entity looking at the same physical memory the cpu is, such as a device.
But that absolutely is not what is happening here, you're doing one MMIO to non-physical memory after another.
drivers/net/fddi/defza.c line 250
Quoted 6 lines
drivers/net/fddi/defza.c new file +6
-0+{ +uint status, state; + +unsigned long int flags; +long int t; +
Use "unsigned int" and "long", and also please do not put empty lines in the middle of the function variable declarations.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + pr_info("%s: resetting the board...\n", fp->name);
Do not put more than one empty line between the local variables and the first non-declaration statement of the function.
drivers/net/fddi/defza.c line 285
Quoted 2 lines
drivers/net/fddi/defza.c new file +2
-0+static struct fza_ring_cmd __iomem *fza_cmd_send (struct net_device *dev, +int command)
When a function declaration or definition or call spans multiple lines, the second and subsequent lines should be indented to exactly the first column after the openning parenthesis.
You must use the appropriate number of TAB and SPACE characters necessary to do so. Generally speaking, if you are only using TAB characters you are indenting it incorrectly.
I'm sure there are lots of other coding style issues, please run checkpatch on your changes unless you want to go back and forth in review several more times as we find them too :-)
As per these SMT packets, don't even publish them to network taps.
We would have never seen them anyways, so keep them completely internal to your driver.
That way you have no reason ti poke into internals like ptype_all and dev_queue_xmit_nit().
Quoted 10 lines · David Miller
drivers/net/fddi/defza.c line 222
Quoted 7 lines
drivers/net/fddi/defza.c new file +7
-0+/* Reset the board. */ +wmb (); +writew (FZA_RESET_INIT , &fp->regs->reset); +iob (); +readw (&fp->regs->reset);/* Read it back for a small delay. */ +iob (); +writew (FZA_RESET_CLR , &fp->regs->reset);Using memory barriers around MMIO operations makes zero sense.
Quoted 6 lines
wmb()and friends order physical memory operations, and are only to be used when the cpu must be synchronized with some other entity looking at the same physical memory the cpu is, such as a device.But that absolutely is not what is happening here, you're doing one MMIO to non-physical memory after another.
This is not perfect, I admit, the issue here however is the MIPS R4400
processor that is used with some systems that support this FDDI adapter has a weakly ordered write buffer, an uncached read issued to an MMIO device can be reordered in front of an earlier uncached write, bypassing the buffer. Additionally the MIPS R3000 processor used on other systems has the R3220 write buffer that can merge multiple writes into one, or supply a value previously written from the buffer before it has reached the destination. Therefore a synchronisation barrier is required.
The architecturally guaranteed barrier operation for the R4400 processor
is the SYNC processor instruction. For the R3000 processor the barrier is platform specific, we have suitable handlers in place (traditionally called wbflush, as they simply spin-wait until the write buffer has drained by itself).
Additionally in some cases, where an immediate effect is required we need
to issue a read (to any location) so that the SYNC instruction actually drains the write buffer (for the R3000 obviously the lone wbflush suffices, and this is reflected in the handlers).
This has been discussed before and we lack a general abstraction layer --
the assumptions we have throughout suitable e.g. for PCI systems do not necessarily stand for non-PCI MIPS systems. It happens however that for systems this driver can support (i.e. MIPS, plus possibly Alpha and VAX; I have actually successfully used an earlier version of this driver with a VAX) these barrier handlers are good enough:
1. For Alpha, where these handlers originate from, MB and WMB are hardware instructions defined both for MP memory and I/O (even UP), with the usual semantics.
2. For MIPS we have equivalent handlers in place, also working with both MP memory and I/O.
3. VAX is strongly ordered, all these handlers are nil.
4. iob is an extension defined for MIPS so far that uses the fastest read operation available -- this is needed by the CPU and its any write buffers only (TURBOchannel itself doesn't do write posting), so with the read-back there's little sense in e.g. going down to TURBOchannel that is always slower than the CPU bus and in some cases much slower.
This approach has already been used with other TURBOchannel and DECstation support code, however as I noted above I wouldn't mind a cleaner solution.
I have now dug deeper and I can see the PPC port (only) has these:
#define iobarrier_rw() eieio()
#define iobarrier_r() eieio()
#define iobarrier_w() eieio()
which look like the right starting point to me. I would then add:
#define iobarrier_rw() mb() #define iobarrier_r() rmb() #define iobarrier_w() wmb()
#define iobarrier_sync() iob()
(or any equivalent code on the RHS as I see fit) for the MIPS platform if we agree this is the right internal API, and update the driver and any other code I look after accordingly. Platform maintainers could then add implementations as they consider required -- the strongly-ordered default could simply be:
#define iobarrier_rw()
etc.
I can see we have a mmiowb handler too, defined across all ports,
analogous to iobarrier_w, but its definition is IIUC wrong for some, e.g. it's empty for Alpha and PPC, where it should be defined to wmb() and eieio() respectively. Anyway the name does not matter, I can take votes for iobarrier_* vs mmio*b as long as we agree on the API itself. :)
I've added some CCs so that non-networking people can chime in on this
part.
Quoted 9 lines
drivers/net/fddi/defza.c line 250
Quoted 6 lines
drivers/net/fddi/defza.c new file +6
-0+{ +uint status, state; + +unsigned long int flags; +long int t; +Use "unsigned int" and "long", and also please do not put empty lines in the middle of the function variable declarations.
Done.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + pr_info("%s: resetting the board...\n", fp->name);Do not put more than one empty line between the local variables and the first non-declaration statement of the function.
Likewise.
[This and the above (except from "long int", that was an oversight) was
done for readability purposes, but I won't insist, it's not important enough to me.]
Quoted 6 lines
drivers/net/fddi/defza.c line 285
Quoted 2 lines
drivers/net/fddi/defza.c new file +2
-0+static struct fza_ring_cmd __iomem *fza_cmd_send (struct net_device *dev, +int command)When a function declaration or definition or call spans multiple lines, the second and subsequent lines should be indented to exactly the first column after the openning parenthesis.
The line you quoted however is exactly right. :) Please mind the + added
by diff offsetting the first but not the second line quoted.
Quoted 3 lines
You must use the appropriate number of TAB and SPACE characters necessary to do so. Generally speaking, if you are only using TAB characters you are indenting it incorrectly.
Or I am good at hitting columns at multiples of 8 with the opening
bracket perhaps? ;)
Quoted 3 lines
I'm sure there are lots of other coding style issues, please run checkpatch on your changes unless you want to go back and forth in review several more times as we find them too :-)
Well, I tried my best and the last time I ran it on this change the
script only had issues with the barriers we've been discussing at the beginning (and which hopefully we'll settle on one way or another), and comments. The latter of which I consider a result of the script being too picky or maybe even entirely wrong, given e.g.:
#define FZA_EVENT_HB_PARITY_ERR 0x0100 /* host bus parity error */
#define FZA_EVENT_NXM_ERR 0x0080 /* non-existent memory access error;
also raised for unaligned and unsupported partial-word accesses */
#define FZA_EVENT_LINK_ST_CHG 0x0040 /* link status change */
where the three comments are simply consistent with one another. If you want them changed to:
#define FZA_EVENT_HB_PARITY_ERR 0x0100 /* host bus parity error */
#define FZA_EVENT_NXM_ERR 0x0080 /* non-existent memory access error;
* also raised for unaligned and
* unsupported partial-word accesses */
#define FZA_EVENT_LINK_ST_CHG 0x0040 /* link status change */
though, then I won't insist on keeping my style, that's not important enough for me, even though the latter version hurts my eye a bit.
Ah, it had something to say about 2 messages split between lines too, but
I refuse to go beyond 79 columns, sorry.
Quoted 7 lines
As per these SMT packets, don't even publish them to network taps.
We would have never seen them anyways, so keep them completely internal to your driver.
That way you have no reason ti poke into internals like
ptype_allanddev_queue_xmit_nit().
That however I would like to keep -- I find it particularly valuable and
a great advantage of this piece of hardware to be able to tap into all the SMT traffic crossing this adapter, both incoming and outgoing, for educational and diagnostic purposes. Without this capability a second FDDI station is required to be able to see both traffic streams, and also it has to be exactly the next downstream neighbour or some traffic will undoubtedly be stripped from the ring by intermediate stations.
Therefore I would like to retain this capability. If you're unhappy with
tapping in directly, then I think sending them back down the usual receive path would do, although at some performance hit. So I'd prefer to avoid it if possible -- can you propose an alternative by any chance?
Thanks for your review, please let me know how to proceed with the issues
that remain open. I'll send updated code once we've settled, I think there's little point in publishing an update before then.
Maciej
David Miller
maintainerFrom: "Maciej W. Rozycki" <[email protected]>
Date: Mon, 28 Apr 2014 12:37:08 +0100 (BST)
Quoted 8 lines
That however I would like to keep -- I find it particularly valuable and
a great advantage of this piece of hardware to be able to tap into all the SMT traffic crossing this adapter, both incoming and outgoing, for educational and diagnostic purposes. Without this capability a second FDDI station is required to be able to see both traffic streams, and also it has to be exactly the next downstream neighbour or some traffic will undoubtedly be stripped from the ring by intermediate stations.
Quoted 8 lines
Therefore I would like to retain this capability. If you're unhappy with
tapping in directly, then I think sending them back down the usual receive path would do, although at some performance hit. So I'd prefer to avoid it if possible -- can you propose an alternative by any chance?Thanks for your review, please let me know how to proceed with the issues
that remain open. I'll send updated code once we've settled, I think there's little point in publishing an update before then.
We're not exporting all of these internals for the unique desires of one single driver.