Skip to contentSkip to conversation

Renesas Ethernet AVB driver proper

PATCH Applied Sergei Shtylyov 2 participants 2 messages Jun 10, 2015 – Jun 11, 2015

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/2 Renesas Ethernet AVB driver proper

Ethernet AVB includes an Gigabit Ethernet controller (E-MAC) that is basically compatible with SuperH Gigabit Ethernet E-MAC. Ethernet AVB has a dedicated direct memory access controller (AVB-DMAC) that is a new design compared to the SuperH E-DMAC. The AVB-DMAC is compliant with 3 standards formulated for IEEE 802.1BA: IEEE 802.1AS timing and synchronization protocol, IEEE 802.1Qav real- time transfer, and the IEEE 802.1Qat stream reservation protocol.

The driver only supports device tree probing, so the binding document is included in this patch.

Based on the original patches by Mitsuhiro Kimura.

---
This patch is against David Miller's 'net-next.git' repo.

Changes in version 6:
- switched to also handling the network control RX/TX queues via NAPI;
- started calling napi_gro_receive() instead of netif_receive_skb();
- removed NULL checks for the 'quota' parameter to ravb_rx() since now it's always gets called with non-NULL argument;
- turned the assignments to the intializers in ravb_interrupt();
- moved ravb_write() call clearing TIS.TFUF interrupt into the code handling this specific interrupt.

Changes in version 5:
- switched to calling multiqueue APIs, implementing ndo_select_queue() method;
- fixed the ring-full check in ravb_start_xmit() and turned it into a "sanity check", adjusting the error message and promoting dev_warn() to dev_err();
- fixed skb_put_padto() failure path to drop the packet;
- moved the 'priv->cur_tx' increment after enqueuing the packet in ravb_start_xmit();
- added the ring-full check after the packet gets enqueued in ravb_start_xmit(), moved ravb_tx_free() call from the sanity check to this new code;
- moved mmiowb() call after the 'exit' label in ravb_start_xmit();
- removed superfluous netif_tx_disable() call from ravb_set_ringparam().

Changes in version 4:
- switched from the bit fields in the descriptor structures to normal fields and masks;
- declared 16/32-bit descriptor fields as '__le{16/32}' and started using cpu_to_le{16|32}() and le{16|32}_to_cpu() when accessing them;
- started registering/deregistering the PTP driver each time the AVB-DMAC enters/leaves the operation mode instead of navb_{probe|remove}(), and thus removed ravb_ptp_is_config() and also the checks in ravb_ptp_tcr_request(), ravb_ptp_time_write(), and ravb_ptp_update_addend();
- folded ravb_free_dma_buffer() into ravb_ring_free(), clarified the comment to the latter function; was then able to simplify the error cleanup path in ravb_ring_init();
- fixed totally brain damaged ravb_tx_timeout() by first stopping DMA and then calling ravb_ring_free() and moving most of the code into work-queue function,
- started calling ravb_ring_init() from ravb_dmac_init();
- started allocating the TX buffers with GPF_KERNEL instead of GPF_ATOMIC;
- started checking the result of ravb_wait() where it was previously ignored;
- propagated errors from ravb_wait() calls outside ravb_ptp_tcr_request();
- propagated errors from ravb_ptp_tcr_request() calls outside ravb_ptp_time_{read|write}();
- propagated errors from ravb_ptp_time_{read|write}() outside ravb_ptp_adjtime() and ravb_ptp_{get|set}time64();
- switched from using ravb_wait() after setting a bit in the GCCR register to just checking if a bit is zero before setting it in ravb_ptp_time_write(), ravb_ptp_select_counter(), and ravb_ptp_update_addend();
- added check for ravb_ptp_update_compare() failure to ravb_ptp_perout() and propagate the error outside this function;
- added mmiowb() calls before releasing the spinlock;
- merged the spinlock release code from different *if* statement branches in ravb_ptp_ptp_perout();
- fixed the 'reg' parameter type in ravb_wait();
- fixed the result type for ravb_start_xmit();
- fixed the 'request' parameter type in ravb_ptp_tcr_request();
- added the 'size' local variable in ravb_tx_free();
- fixed TX ring cleanup threshold in ravb_start_xmit();
- fixed kmalloc() error cleanup in ravb_start_xmit();
- fixed ravb_start_xmit() racing with the interrupt handler and NAPI poller by holding spinlock till the end of ravb_start_xmit();
- factored out the GIC interrupt handling into ravb_ptp_interrupt();
- added the 'dma_addr' local variable in ravb_start_xmit();
- switched from '%=' operator to '&=' in ravb_start_xmit();
- changed the format specifier in ravb_tx_timeout();
- removed useless type cast from ravb_rx();
- acquired the spinlock earlier in ravb_poll();
- made ravb_ptp_init() return *void* since its result isn't checked anyway;
- removed 'ravb_private::rx_buffer_size' since the RX buffer size should be constant;
- removed unused 'ravb_private::edmac_endian';
- expanded update_mac_address() inline at its only call site;
- expanded ravb_ptp_cnt_{read|write}() inline at their single call sites;
- expanded ravb_ptp_cnt_select_counter() inline at its only call site;
- expanded ravb_ptp_update_addend() at its only call site;
- added 'ravb_' prefix to read_mac_address();
- renamed ravb_wait_stop_dma() to ravb_stop_dma();
- also disabled E-MAC TX in ravb_stop_dma() by calling ravb_rcv_snd_disable();
- moved the ravb_config() call from ravb_stop_dma() callers to this function;
- removed redundant register reads/writes in ravb_set_duplex();
- converted the 'new_state' local variable from *int* to *bool* in ravb_adjust_link();
- converted the 'neg_adj' local variable from *int* to *bool* in ravb_ptp_adjfreq();
- removed duplicate 'ndev->netdev_ops' assignment in ravb_probe();
- removed redundant clearing of the statisitics counters in ravb_probe();
- removed useless 'priv->num_[rt]x_ring[RAVB_NC]' assignments in ravb_set_ringparam();
- removed the 'adj' local variable in ravb_ptp_adjfreq();
- started printing the error value after ravb_dmac_init() call failure in ravb_set_ringparam();
- removed unused #define NC_[RT]X_RING_{MIN|MAX};
- removed unused #define TX_TIMEOUT;
- moved #define RAVB_ALIGN and timestamp flag #define's after the registers *enum* declaration;
- moved 'struct ravb_desc' before the descriptor type *enum* declaration;
- moved 'enum RAVB_QUEUE' before the group of #define's that preceded it;
- split the header file from the driver, split the PTP driver into its own file and a separate patch, adjusted the changelog accordingly;
- converted ravb_wait() from *static* to *extern* for use by the PTP driver;
- converted ravb_ptp_{init|stop}() from *static* to *extern* tor call it from the Ethernet driver proper;
- fixed "transmited" in the comments thoughout;
- added "the" to the "caller must hold lock" comments thoughout;
- created the Renesas submenu in the Kconfig file.

Changes in version 3:
- fixed errors due to the PTP core having switched to using 'struct timespec64' to get/set time, renaming ravb_ptp_{get|set}time();
- fixed type cast warning in ravb_set_buffer_align();
- removed memory allocation failure message from ravb_start_xmit();
- added 'irq' local variable in ravb_probe();
- rephrased error messages in ravb_config() and ravb_close();
- lowercased the first letter of the driver messages throughout;
- renamed the 'result' local variables to 'error' throughout.

Changes in version 2:
- fixed the bug where interrupts weren't re-enabled in ravb_set_ringparam();
- added netif_device_{detach|attach}() calls to ravb_set_ringparam(), fixing TX watchdog being fired during ring resize;
- made ravb_ring_{init|free}(), ravb_free_dma_buffer(), and ravb_[ed]mac_init() calls conditional fixing crash/memory leak when resizing rings of a closed device;
- fixed the order of setting SKBTX_IN_PROGRESS and skb_tx_timestamp() calls;
- implemented ndo_set_rx_mode() method;
- implemented SIOCGHWTSTAMP ioctl(), turning *if* statement in ravb_do_ioctl() into *switch*;
- merged ravb_wait_clear() and ravb_wait_setting() into ravb_wait(), switching to 100 times more frequent polling and simplfying the code;
- replaced unbounded register polling loops with ravb_wait() calls;
- switched to using 'struct timespec64' instead of 'struct timespec' whenever possible, adding code to read/write extra PTP registers;
- added dma_[rw]mb() barrier calls where needed (with comments);
- renamed ravb_reset() to ravb_config(), fixed the comment grammar there;
- renamed ravb_mac_init() to ravb_emac_init(), removing now unneeded parameter, renamed local variable there, simplified the expression assigned to that variable;
- removed now unneeded parameter from ravb_dmac_init() along with the code disabling interrupts, moved netif_start_queue() from this function to its callers;
- renamed ravb_hwtstamp_ioctl() to ravb_hwtstamp_set(), renaming the 2nd parameter, removing unused 3rd parameter, and turning the initializer for one of the local variables into assignment;
- removed unused parameter from ravb_rx();
- renamed variables in ravb_get_tx_tstamp() and ravb_close();
- changed the "compatible" property values;
- removed unneeded parens and netif_queue_stopped() call in ravb_poll(), fixed the comment there;
- simplified ravb_ptp_is_config();
- realigned some lines/names/operators throughout;
- sorted the variable declarations by length descending thoughout;
- capitalize the first letter in the comments thoughout;
- added Masaru Nagai to MODULE_AUTHOR();
- mentioned the PTP driver in the changelog;
- added original authors' sign-offs.

 Documentation/devicetree/bindings/net/renesas,ravb.txt |   48 
 drivers/net/ethernet/renesas/Kconfig                   |   31 
 drivers/net/ethernet/renesas/Makefile                  |    1 
 drivers/net/ethernet/renesas/ravb.c                    | 1801 +++++++++++++++++
 drivers/net/ethernet/renesas/ravb.h                    |  806 +++++++
 5 files changed, 2687 insertions(+)
Documentation/devicetree/bindings/net/renesas,ravb.txt new file +48 -0
Index: net-next/Documentation/devicetree/bindings/net/renesas,ravb.txt
===================================================================
@@ -0,0 +1,48 @@
+* Renesas Electronics Ethernet AVB
+
+This file provides information on what the device node for the Ethernet AVB
+interface contains.
+
+Required properties:
+- compatible: "renesas,etheravb-r8a7790" if the device is a part of R8A7790 SoC.
+	      "renesas,etheravb-r8a7794" if the device is a part of R8A7794 SoC.
+- reg: offset and length of (1) the register block and (2) the stream buffer.
+- interrupts: interrupt specifier for the sole interrupt.
+- phy-mode: see ethernet.txt file in the same directory.
+- phy-handle: see ethernet.txt file in the same directory.
+- #address-cells: number of address cells for the MDIO bus, must be equal to 1.
+- #size-cells: number of size cells on the MDIO bus, must be equal to 0.
+- clocks: clock phandle and specifier pair.
+- pinctrl-0: phandle, referring to a default pin configuration node.
+
+Optional properties:
+- interrupt-parent: the phandle for the interrupt controller that services
+		    interrupts for this device.
+- pinctrl-names: pin configuration state name ("default").
+- renesas,no-ether-link: boolean, specify when a board does not provide a proper
+			 AVB_LINK signal.
+- renesas,ether-link-active-low: boolean, specify when the AVB_LINK signal is
+				 active-low instead of normal active-high.
+
+Example:
+
+	ethernet@e6800000 {
+		compatible = "renesas,etheravb-r8a7790";
+		reg = <0 0xe6800000 0 0x800>, <0 0xee0e8000 0 0x4000>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 163 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp8_clks R8A7790_CLK_ETHERAVB>;
+		phy-mode = "rmii";
+		phy-handle = <&phy0>;
+		pinctrl-0 = <&ether_pins>;
+		pinctrl-names = "default";
+		renesas,no-ether-link;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		phy0: ethernet-phy@0 {
+			reg = <0>;
+			interrupt-parent = <&gpio2>;
+			interrupts = <15 IRQ_TYPE_LEVEL_LOW>;
+		};
+	};
drivers/net/ethernet/renesas/Kconfig +31 -0
Index: net-next/drivers/net/ethernet/renesas/Kconfig
===================================================================
@@ -2,6 +2,21 @@
 # Renesas device configuration
 #
 
+config NET_VENDOR_RENESAS
+	bool "Renesas devices"
+	default y
+	---help---
+	  If you have a network (Ethernet) card belonging to this class, say Y
+	  and read the Ethernet-HOWTO, available from
+	  <http://www.tldp.org/docs.html#howto>.
+
+	  Note that the answer to this question doesn't directly affect the
+	  kernel: saying N will just cause the configurator to skip all
+	  the questions about Renesas devices. If you say Y, you will be asked
+	  for your specific device in the following questions.
+
+if NET_VENDOR_RENESAS
+
 config SH_ETH
 	tristate "Renesas SuperH Ethernet support"
 	depends on HAS_DMA
@@ -15,3 +30,19 @@ config SH_ETH
 	  This driver supporting CPUs are:
 		- SH7619, SH7710, SH7712, SH7724, SH7734, SH7763, SH7757,
 		  R8A7740, R8A777x and R8A779x.
+
+config RAVB
+	tristate "Renesas Ethernet AVB support"
+	depends on HAS_DMA
+	depends on ARCH_SHMOBILE || COMPILE_TEST
+	select CRC32
+	select MII
+	select MDIO_BITBANG
+	select PHYLIB
+	select PTP_1588_CLOCK
+	help
+	  Renesas Ethernet AVB device driver.
+	  This driver supports the following SoCs:
+		- R8A779x.
+
+endif # NET_VENDOR_RENESAS
drivers/net/ethernet/renesas/Makefile +1 -0
Index: net-next/drivers/net/ethernet/renesas/Makefile
===================================================================
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_SH_ETH) += sh_eth.o
+obj-$(CONFIG_RAVB) += ravb.o
drivers/net/ethernet/renesas/ravb.c new file +1801 -0

1,801 lines not on this page · raw message

drivers/net/ethernet/renesas/ravb.h new file +806 -0

806 lines not on this page · raw message

maintainer Applied
#1 lore raw

From: Sergei Shtylyov <[email protected]>
Date: Thu, 11 Jun 2015 01:01:43 +0300

Quoted 7 lines

Ethernet AVB includes an Gigabit Ethernet controller (E-MAC) that is basically compatible with SuperH Gigabit Ethernet E-MAC. Ethernet AVB has a dedicated direct memory access controller (AVB-DMAC) that is a new design compared to the SuperH E-DMAC. The AVB-DMAC is compliant with 3 standards formulated for IEEE 802.1BA: IEEE 802.1AS timing and synchronization protocol, IEEE 802.1Qav real- time transfer, and the IEEE 802.1Qat stream reservation protocol.

Quoted 7 lines

The driver only supports device tree probing, so the binding document is included in this patch.

Based on the original patches by Mitsuhiro Kimura.

Applied.