Re: Gigabit ethernet driver for Alacritechs SLIC devices (v4)
On 06.12.2016 17:30, David Miller wrote: > From: Lino Sanfilippo > Date: Mon, 5 Dec 2016 23:07:15 +0100 > >> this is the forth version of the slicoss gigabit ethernet driver (which is a >> rework of the driver from Alacritech which can currently be found under >> drivers/staging/slicoss). The driver is supposed to support Mojave, Oasis and >> Kalahari cards, for both copper and fiber. >> >> If this code is accepted the staging version can be removed. >> >> The driver has been tested on a SEN2104ET adapter (4 Port PCIe copper). > > I've applied this series, nice work. > Great, thanks! Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Add driver for Alacritech gigabit ethernet cards with SLIC (session-layer interface control) technology. The driver provides basic support without SLIC for the following devices: - Mojave cards (single port PCI Gigabit) both copper and fiber - Oasis cards (single and dual port PCI-x Gigabit) copper and fiber - Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber Signed-off-by: Lino Sanfilippo --- drivers/net/ethernet/Kconfig |1 + drivers/net/ethernet/Makefile |1 + drivers/net/ethernet/alacritech/Kconfig | 28 + drivers/net/ethernet/alacritech/Makefile |4 + drivers/net/ethernet/alacritech/slic.h| 575 + drivers/net/ethernet/alacritech/slicoss.c | 1882 + 6 files changed, 2491 insertions(+) create mode 100644 drivers/net/ethernet/alacritech/Kconfig create mode 100644 drivers/net/ethernet/alacritech/Makefile create mode 100644 drivers/net/ethernet/alacritech/slic.h create mode 100644 drivers/net/ethernet/alacritech/slicoss.c diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index 2ffd634..a4cc87fe 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -21,6 +21,7 @@ source "drivers/net/ethernet/3com/Kconfig" source "drivers/net/ethernet/adaptec/Kconfig" source "drivers/net/ethernet/aeroflex/Kconfig" source "drivers/net/ethernet/agere/Kconfig" +source "drivers/net/ethernet/alacritech/Kconfig" source "drivers/net/ethernet/allwinner/Kconfig" source "drivers/net/ethernet/alteon/Kconfig" source "drivers/net/ethernet/altera/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 1d349e9..b448027 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_NET_VENDOR_8390) += 8390/ obj-$(CONFIG_NET_VENDOR_ADAPTEC) += adaptec/ obj-$(CONFIG_GRETH) += aeroflex/ obj-$(CONFIG_NET_VENDOR_AGERE) += agere/ +obj-$(CONFIG_NET_VENDOR_ALACRITECH) += alacritech/ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/ obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ obj-$(CONFIG_ALTERA_TSE) += altera/ diff --git a/drivers/net/ethernet/alacritech/Kconfig b/drivers/net/ethernet/alacritech/Kconfig new file mode 100644 index 000..09496e1 --- /dev/null +++ b/drivers/net/ethernet/alacritech/Kconfig @@ -0,0 +1,28 @@ +config NET_VENDOR_ALACRITECH + bool "Alacritech devices" + default y + ---help--- + If you have a network (Ethernet) card belonging to this class, say Y. + + 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 Alacritech devices. If you say Y, you will be asked + for your specific device in the following questions. + +if NET_VENDOR_ALACRITECH + +config SLICOSS + tristate "Alacritech Slicoss support" + depends on PCI + select CRC32 + ---help--- + This driver supports Gigabit Ethernet adapters based on the + Session Layer Interface (SLIC) technology by Alacritech. + + Supported are Mojave (1 port) and Oasis (1, 2 and 4 port) cards, + both copper and fiber. + + To compile this driver as a module, choose M here: the module + will be called slicoss. This is recommended. + +endif # NET_VENDOR_ALACRITECH diff --git a/drivers/net/ethernet/alacritech/Makefile b/drivers/net/ethernet/alacritech/Makefile new file mode 100644 index 000..8790e9e --- /dev/null +++ b/drivers/net/ethernet/alacritech/Makefile @@ -0,0 +1,4 @@ +# +# Makefile for the Alacritech Slicoss driver +# +obj-$(CONFIG_SLICOSS) += slicoss.o diff --git a/drivers/net/ethernet/alacritech/slic.h b/drivers/net/ethernet/alacritech/slic.h new file mode 100644 index 000..08931b4 --- /dev/null +++ b/drivers/net/ethernet/alacritech/slic.h @@ -0,0 +1,575 @@ + +#ifndef _SLIC_H +#define _SLIC_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SLIC_VGBSTAT_XPERR 0x4000 +#define SLIC_VGBSTAT_XERRSHFT 25 +#define SLIC_VGBSTAT_XCSERR0x23 +#define SLIC_VGBSTAT_XUFLOW0x22 +#define SLIC_VGBSTAT_XHLEN 0x20 +#define SLIC_VGBSTAT_NETERR0x0100 +#define SLIC_VGBSTAT_NERRSHFT 16 +#define SLIC_VGBSTAT_NERRMSK 0x1ff +#define SLIC_VGBSTAT_NCSERR0x103 +#define SLIC_VGBSTAT_NUFLOW0x102 +#define SLIC_VGBSTAT_NHLEN 0x100 +#define SLIC_VGBSTAT_LNKERR0x0080 +#define SLIC_VGBSTAT_LERRMSK 0xff +#define SLIC_VGBSTAT_LDEARLY 0x86 +#define SLIC_VGBSTAT_LBOFLO0x85 +#define SLIC_VGBSTAT_LCODERR 0x84 +#define SLIC_VGBSTAT_LDBLNBL 0x83 +#define SLIC_VGBSTAT_LCRCERR
[PATCH v4 net-next 2/2] MAINTAINERS: add entry for slicoss ethernet driver
Add myself as maintainer for the slicoss ethernet driver. Signed-off-by: Lino Sanfilippo --- MAINTAINERS | 5 + 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6781a3f..bb9af28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -562,6 +562,11 @@ T: git git://linuxtv.org/anttip/media_tree.git S: Maintained F: drivers/media/usb/airspy/ +ALACRITECH GIGABIT ETHERNET DRIVER +M: Lino Sanfilippo +S: Maintained +F: drivers/net/ethernet/alacritech/* + ALCATEL SPEEDTOUCH USB DRIVER M: Duncan Sands L: linux-...@vger.kernel.org -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Gigabit ethernet driver for Alacritechs SLIC devices (v4)
Hi, this is the forth version of the slicoss gigabit ethernet driver (which is a rework of the driver from Alacritech which can currently be found under drivers/staging/slicoss). The driver is supposed to support Mojave, Oasis and Kalahari cards, for both copper and fiber. If this code is accepted the staging version can be removed. The driver has been tested on a SEN2104ET adapter (4 Port PCIe copper). v4: - fix wrong driver name in Kconfig file (reported by Rami Rosen) - remove unused variable from driver struct (reported by Rami Rosen) - return "err" instead of 0 in slic_load_rcvseq_firmware() (reported by Rami Rosen) - Fix typos in constants, comments and error message (reported by Markus Böhme) - fix various warnings concerning signedness (reported by Markus Böhme) - improve line formatting (reported by Markus Böhme) - add comment describing the need for SLIC_MAX_TX_COMPLETIONS (suggested by Florian Fainelli) - do not zero out complete rx descriptor (suggested by Florian Fainelli) - add missing write barrier (reported by Florian Fainelli) - remove unneeded assignment of net_device to skb (reported by Florian Fainelli) - use napi_complete_done() instead of napi_complete (suggested by Florian Fainelli) - use napi_schedule_irqoff() instead of napi_schedule (suggested by Florian Fainelli) - do not map error returned by slic_init() to -ENOMEM - do proper dma syncs before and after rx descriptor status is set to 0 - if after dma sync for CPU rx descriptor is not used return it to HW by means of dma sync for device v3: - dont add defines to pci_ids.h but instead put it into the drivers header file (requested by Greg Kroah-Hartman) v2: - remove unusual padding in statistic strings (suggested by Andrew Lunn) - for mdio register and bit names use defines from mii.h instead of own ones (suggested by Andrew Lunn) - remove unused defines - ensure PCI flush at two more places - use mmiowb before lock to prevent mmio writes leaking out of lock - fix some typos in comments - add copyright and GPL header Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
On 29.11.2016 18:14, Florian Fainelli wrote: > On 11/28/2016 01:41 PM, Lino Sanfilippo wrote: >> The problem is that the HW does not provide a tx completion index. Instead >> we have to >> iterate the status descriptors until we get an invalid idx which indicates >> that there >> are no further tx descriptors done for now. I am afraid that if we do not >> limit the >> number of descriptors processed in the tx completion handler, a continuous >> transmission >> of frames could keep the loop in xmit_complete() run endlessly. I dont know >> if this >> can actually happen but I wanted to make sure that this is avoided. > > OK, it might be a good idea to put that comment somewhere around the tx > completion handler to understand why it is bounded with a specific value. > Agreed, I will add such a comment. >> >>> [snip] >>> >>>> + while (slic_get_free_rx_descs(rxq) > SLIC_MAX_REQ_RX_DESCS) { >>>> + skb = alloc_skb(maplen + ALIGN_MASK, gfp); >>>> + if (!skb) >>>> + break; >>>> + >>>> + paddr = dma_map_single(&sdev->pdev->dev, skb->data, maplen, >>>> + DMA_FROM_DEVICE); >>>> + if (dma_mapping_error(&sdev->pdev->dev, paddr)) { >>>> + netdev_err(dev, "mapping rx packet failed\n"); >>>> + /* drop skb */ >>>> + dev_kfree_skb_any(skb); >>>> + break; >>>> + } >>>> + /* ensure head buffer descriptors are 256 byte aligned */ >>>> + offset = 0; >>>> + misalign = paddr & ALIGN_MASK; >>>> + if (misalign) { >>>> + offset = SLIC_RX_BUFF_ALIGN - misalign; >>>> + skb_reserve(skb, offset); >>>> + } >>>> + /* the HW expects dma chunks for descriptor + frame data */ >>>> + desc = (struct slic_rx_desc *)skb->data; >>>> + memset(desc, 0, sizeof(*desc)); >>> >>> Do you really need to zero-out the prepending RX descriptor? Are not you >>> missing a write barrier here? >> >> Indeed, it should be sufficient to make sure that the bit SLIC_IRHDDR_SVALID >> is not set. >> I will adjust it. >> Concerning the write barrier: You mean a wmb() before slic_write() to ensure >> that the zeroing >> of the status desc is done before the descriptor is passed to the HW, right? > > Correct, that's what I meant here. > Ok, will fix this. Good catch BTW! >> >>> [snip] >>> >>>> + >>>> + dma_sync_single_for_cpu(&sdev->pdev->dev, >>>> + dma_unmap_addr(buff, map_addr), >>>> + buff->addr_offset + sizeof(*desc), >>>> + DMA_FROM_DEVICE); >>>> + >>>> + status = le32_to_cpu(desc->status); >>>> + if (!(status & SLIC_IRHDDR_SVALID)) >>>> + break; >>>> + >>>> + buff->skb = NULL; >>>> + >>>> + dma_unmap_single(&sdev->pdev->dev, >>>> + dma_unmap_addr(buff, map_addr), >>>> + dma_unmap_len(buff, map_len), >>>> + DMA_FROM_DEVICE); >>> >>> This is potentially inefficient, you already did a cache invalidation >>> for the RX descriptor here, you could be more efficient with just >>> invalidating the packet length, minus the descriptor length. >>> >> >> I am not sure I understand: We have to unmap the complete dma area, no >> matter if we synced >> part of it before, dont we? AFAIK a dma sync is different from unmapping >> dma, or do I miss >> something? > > Sorry, I was not very clear, what I meant is that you can allocate and > do the initial dma_map_single() of your RX skbs during ndo_open(), and > then, in your RX path, you can only do dma_sync_single_for_cpu() twice > (once for the RX descriptor status, second time for the actual packet > contents), and when you return the SKB to the HW, do a > dma_sync_single_for_device(). The advantage of doing that, is that if > your cache operations are slow, you only do them on exactly packet > length, and not the actual RX buffer size (e.g: 2KB). Um. In
Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi Florian, On 28.11.2016 05:56, Florian Fainelli wrote: > On 11/26/2016 04:20 AM, Lino Sanfilippo wrote: >> Add driver for Alacritech gigabit ethernet cards with SLIC (session-layer >> interface control) technology. The driver provides basic support without >> SLIC for the following devices: >> >> - Mojave cards (single port PCI Gigabit) both copper and fiber >> - Oasis cards (single and dual port PCI-x Gigabit) copper and fiber >> - Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber > > This looks great, a few nits below: > > >> +#define SLIC_MAX_TX_COMPLETIONS 100 > > You usually don't want to limit the number of TX completion, if the > entire TX ring needs to be cleaned, you would want to allow that. > The problem is that the HW does not provide a tx completion index. Instead we have to iterate the status descriptors until we get an invalid idx which indicates that there are no further tx descriptors done for now. I am afraid that if we do not limit the number of descriptors processed in the tx completion handler, a continuous transmission of frames could keep the loop in xmit_complete() run endlessly. I dont know if this can actually happen but I wanted to make sure that this is avoided. > [snip] > >> +while (slic_get_free_rx_descs(rxq) > SLIC_MAX_REQ_RX_DESCS) { >> +skb = alloc_skb(maplen + ALIGN_MASK, gfp); >> +if (!skb) >> +break; >> + >> +paddr = dma_map_single(&sdev->pdev->dev, skb->data, maplen, >> + DMA_FROM_DEVICE); >> +if (dma_mapping_error(&sdev->pdev->dev, paddr)) { >> +netdev_err(dev, "mapping rx packet failed\n"); >> +/* drop skb */ >> +dev_kfree_skb_any(skb); >> +break; >> +} >> +/* ensure head buffer descriptors are 256 byte aligned */ >> +offset = 0; >> +misalign = paddr & ALIGN_MASK; >> +if (misalign) { >> +offset = SLIC_RX_BUFF_ALIGN - misalign; >> +skb_reserve(skb, offset); >> +} >> +/* the HW expects dma chunks for descriptor + frame data */ >> +desc = (struct slic_rx_desc *)skb->data; >> +memset(desc, 0, sizeof(*desc)); > > Do you really need to zero-out the prepending RX descriptor? Are not you > missing a write barrier here? Indeed, it should be sufficient to make sure that the bit SLIC_IRHDDR_SVALID is not set. I will adjust it. Concerning the write barrier: You mean a wmb() before slic_write() to ensure that the zeroing of the status desc is done before the descriptor is passed to the HW, right? > [snip] > >> + >> +dma_sync_single_for_cpu(&sdev->pdev->dev, >> +dma_unmap_addr(buff, map_addr), >> +buff->addr_offset + sizeof(*desc), >> +DMA_FROM_DEVICE); >> + >> +status = le32_to_cpu(desc->status); >> +if (!(status & SLIC_IRHDDR_SVALID)) >> +break; >> + >> +buff->skb = NULL; >> + >> +dma_unmap_single(&sdev->pdev->dev, >> + dma_unmap_addr(buff, map_addr), >> + dma_unmap_len(buff, map_len), >> + DMA_FROM_DEVICE); > > This is potentially inefficient, you already did a cache invalidation > for the RX descriptor here, you could be more efficient with just > invalidating the packet length, minus the descriptor length. > I am not sure I understand: We have to unmap the complete dma area, no matter if we synced part of it before, dont we? AFAIK a dma sync is different from unmapping dma, or do I miss something? >> + >> +/* skip rx descriptor that is placed before the frame data */ >> +skb_reserve(skb, SLIC_RX_BUFF_HDR_SIZE); >> + >> +if (unlikely(status & SLIC_IRHDDR_ERR)) { >> +slic_handle_frame_error(sdev, skb); >> +dev_kfree_skb_any(skb); >> +} else { >> +struct ethhdr *eh = (struct ethhdr *)skb->data; >> + >> +if (is_multicast_ether_addr(eh->h_dest)) >> +SLIC_INC_STATS_COUNTER(&sdev->stats, rx_mcasts); >> + >> +len = le32_to_cpu(de
Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi Markus, On 27.11.2016 18:59, Markus Böhme wrote: > Hello Lino, > > just some things barely worth mentioning: > > > I found a bunch of unused #defines in slic.h. I cannot judge if they are > worth keeping: > > SLIC_VRHSTATB_LONGE > SLIC_VRHSTATB_PREA > SLIC_ISR_IO > SLIC_ISR_PING_MASK > SLIC_GIG_SPEED_MASK > SLIC_GMCR_RESET > SLIC_XCR_RESET > SLIC_XCR_XMTEN > SLIC_XCR_PAUSEEN > SLIC_XCR_LOADRNG > SLIC_REG_DBAR > SLIC_REG_PING > SLIC_REG_DUMP_CMD > SLIC_REG_DUMP_DATA > SLIC_REG_WRHOSTID > SLIC_REG_LOW_POWER > SLIC_REG_RESET_IFACE > SLIC_REG_ADDR_UPPER > SLIC_REG_HBAR64 > SLIC_REG_DBAR64 > SLIC_REG_CBAR64 > SLIC_REG_RBAR64 > SLIC_REG_WRVLANID > SLIC_REG_READ_XF_INFO > SLIC_REG_WRITE_XF_INFO > SLIC_REG_TICKS_PER_SEC > > These device IDs are not used, either, but maybe it's good to keep them > for documentation purposes: > > PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2 > PCI_SUBDEVICE_ID_ALACRITECH_SES1001T > PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT > PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT > PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET > PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET > I left these defines in for both documentation and to avoid gaps in register ranges. I would like to keep this as it is. >> + >> +/* SLIC EEPROM structure for Oasis */ >> +struct slic_mojave_eeprom { > > Comment: "for Mojave". Will fix, thanks, > > [...] > >> +struct slic_device { >> +struct pci_dev *pdev; >> +struct net_device *netdev; >> +void __iomem *regs; >> +/* upper address setting lock */ >> +spinlock_t upper_lock; >> +struct slic_shmem shmem; >> +struct napi_struct napi; >> +struct slic_rx_queue rxq; >> +struct slic_tx_queue txq; >> +struct slic_stat_queue stq; >> +struct slic_stats stats; >> +struct slic_upr_list upr_list; >> +/* link configuration lock */ >> +spinlock_t link_lock; >> +bool promisc; >> +bool autoneg; >> +int speed; >> +int duplex; > > Maybe make speed and duplex unsigned? They are assigned and compared > against unsigned values in slicoss.c, so this would get rid of some > (benign, because of the range of the values) -Wsign-compare warnings in > slic_configure_link_locked. However, in a comparison there SPEED_UNKNOWN > would need to be casted to unsigned to prevent another one popping up. > There is indeed a bunch of warnings concerning signedness. Will have a look at all of them. However I think I will keep "speed" as an int, because casting SPEED_UNKNOWN to an unsigned int is IMHO an ugly thing to do. > [...] > >> +#endif /* _SLIC_H */ >> diff --git a/drivers/net/ethernet/alacritech/slicoss.c >> b/drivers/net/ethernet/alacritech/slicoss.c >> new file mode 100644 >> index 000..8cd862a >> --- /dev/null >> +++ b/drivers/net/ethernet/alacritech/slicoss.c >> @@ -0,0 +1,1867 @@ > > [...] > >> + >> +static const struct pci_device_id slic_id_tbl[] = { >> +{ PCI_DEVICE(PCI_VENDOR_ID_ALACRITECH, >> + PCI_DEVICE_ID_ALACRITECH_MOAVE) }, > > I missed this in slic.h, but is this a typo and "MOAVE" should be > "MOJAVE"? There are a couple similar #defines in slic.h. This should definitely be "Mojave". Will fix it. > > [...] > >> +static void slic_refill_rx_queue(struct slic_device *sdev, gfp_t gfp) >> +{ >> +const unsigned int ALIGN_MASK = SLIC_RX_BUFF_ALIGN - 1; >> +unsigned int maplen = SLIC_RX_BUFF_SIZE; >> +struct slic_rx_queue *rxq = &sdev->rxq; >> +struct net_device *dev = sdev->netdev; >> +struct slic_rx_buffer *buff; >> +struct slic_rx_desc *desc; >> +unsigned int misalign; >> +unsigned int offset; >> +struct sk_buff *skb; >> +dma_addr_t paddr; >> + >> +while (slic_get_free_rx_descs(rxq) > SLIC_MAX_REQ_RX_DESCS) { >> +skb = alloc_skb(maplen + ALIGN_MASK, gfp); >> +if (!skb) >> +break; >> + >> +paddr = dma_map_single(&sdev->pdev->dev, skb->data, maplen, >> + DMA_FROM_DEVICE); >> +if (dma_mapping_error(&sdev->pdev->dev, paddr)) { >> +netdev_err(dev, "mapping rx packet failed\n"); >> +/* drop skb */ >> +dev_kfree_skb_any(skb); >> +break; >> +} >> +/* ensure head buffer descriptors are 256 byte aligned */ >> +offset = 0; >> +misalign = paddr & ALIGN_MASK; >> +if (misalign) { >> +offset = SLIC_RX_BUFF_ALIGN - misalign; >> +skb_reserve(skb, offset); >> +} >> +/* the HW expects dma chunks for descriptor + frame data */ >> +desc = (struct slic_rx_desc *)skb->data; >> +memset(desc, 0, sizeof(*desc)); >> + >> +buff = &rxq->rxbuffs[rxq->put_idx]; >> +
Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi Rami, On 26.11.2016 16:48, Rami Rosen wrote: >> @@ -0,0 +1,28 @@ >> +config NET_VENDOR_ALACRITECH >> +bool "Alacritech devices" >> +default y >> +---help--- >> + If you have a network (Ethernet) card belonging to this class, >> say Y. >> + >> + Note that the answer to this question doesn't directly affect the >> + kernel: saying N will just cause the configurator to skip all > > Shouldn't it be "Alacritech devices" here, as appears earlier ? > >> + the questions about Renesas devices. If you say Y, you will be >> asked Yes, it definitely should not be Renesas :). This is a stupid copy and paste error, I will fix it, thank you! >> + for your specific device in the following questions. >> + > > ... > ... > ... >> +struct slic_device { >> + struct pci_dev *pdev; > ... >> + bool promisc; > > Seems that the autoneg boolean is not used anywhere, apart from > setting it once to true in > the slic_set_link_autoneg() method. Apart from this member it is not > accessed anywhere, so it seems it should be removed. > >> + bool autoneg; >> + int speed; Agreed, this variable can be removed. > ... > >> +static int slic_load_rcvseq_firmware(struct slic_device *sdev) >> +{ >> + const struct firmware *fw; >> + const char *file; >> + u32 codelen; >> + int idx = 0; >> + u32 instr; >> + u32 addr; >> + int err; >> + > ... >> + /* Do an initial sanity check concerning firmware size now. A further >> +* check follows below. >> +*/ >> + if (fw->size < SLIC_FIRMWARE_MIN_SIZE) { >> + dev_err(&sdev->pdev->dev, >> + "invalid firmware size %zu (min %u expected)\n", >> + fw->size, SLIC_FIRMWARE_MIN_SIZE); >> + err = -EINVAL; > > in the release label, always 0 is returned: > >> + goto release; >> + } >> + >> + codelen = slic_read_dword_from_firmware(fw, &idx); >> + >> + /* do another sanity check against firmware size */ >> + if ((codelen + 4) > fw->size) { >> + dev_err(&sdev->pdev->dev, >> + "invalid rcv-sequencer firmware size %zu\n", >> fw->size); >> + err = -EINVAL; > > Again, in the release label, always 0 is returned: > >> + goto release; >> + } >> + >> >> +release: >> + release_firmware(fw); >> + >> + return 0; >> +} This should return "err", I will fix it. Thanks a lot for the review! Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: Gigabit ethernet driver for Alacritechs SLIC devices (v3)
On 26.11.2016 13:20, Lino Sanfilippo wrote: > v3: > - dont add defines to pci.h but instead put it into the drivers header file This should of course be "pci_ids.h". Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 net-next 2/2] MAINTAINERS: add entry for slicoss ethernet driver
Add myself as maintainer for the slicoss ethernet driver. Signed-off-by: Lino Sanfilippo --- MAINTAINERS | 5 + 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6781a3f..bb9af28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -562,6 +562,11 @@ T: git git://linuxtv.org/anttip/media_tree.git S: Maintained F: drivers/media/usb/airspy/ +ALACRITECH GIGABIT ETHERNET DRIVER +M: Lino Sanfilippo +S: Maintained +F: drivers/net/ethernet/alacritech/* + ALCATEL SPEEDTOUCH USB DRIVER M: Duncan Sands L: linux-...@vger.kernel.org -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Add driver for Alacritech gigabit ethernet cards with SLIC (session-layer interface control) technology. The driver provides basic support without SLIC for the following devices: - Mojave cards (single port PCI Gigabit) both copper and fiber - Oasis cards (single and dual port PCI-x Gigabit) copper and fiber - Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber Signed-off-by: Lino Sanfilippo --- drivers/net/ethernet/Kconfig |1 + drivers/net/ethernet/Makefile |1 + drivers/net/ethernet/alacritech/Kconfig | 28 + drivers/net/ethernet/alacritech/Makefile |4 + drivers/net/ethernet/alacritech/slic.h| 576 + drivers/net/ethernet/alacritech/slicoss.c | 1867 + 6 files changed, 2477 insertions(+) create mode 100644 drivers/net/ethernet/alacritech/Kconfig create mode 100644 drivers/net/ethernet/alacritech/Makefile create mode 100644 drivers/net/ethernet/alacritech/slic.h create mode 100644 drivers/net/ethernet/alacritech/slicoss.c diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index 2ffd634..a4cc87fe 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -21,6 +21,7 @@ source "drivers/net/ethernet/3com/Kconfig" source "drivers/net/ethernet/adaptec/Kconfig" source "drivers/net/ethernet/aeroflex/Kconfig" source "drivers/net/ethernet/agere/Kconfig" +source "drivers/net/ethernet/alacritech/Kconfig" source "drivers/net/ethernet/allwinner/Kconfig" source "drivers/net/ethernet/alteon/Kconfig" source "drivers/net/ethernet/altera/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 1d349e9..b448027 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_NET_VENDOR_8390) += 8390/ obj-$(CONFIG_NET_VENDOR_ADAPTEC) += adaptec/ obj-$(CONFIG_GRETH) += aeroflex/ obj-$(CONFIG_NET_VENDOR_AGERE) += agere/ +obj-$(CONFIG_NET_VENDOR_ALACRITECH) += alacritech/ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/ obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ obj-$(CONFIG_ALTERA_TSE) += altera/ diff --git a/drivers/net/ethernet/alacritech/Kconfig b/drivers/net/ethernet/alacritech/Kconfig new file mode 100644 index 000..41000a3 --- /dev/null +++ b/drivers/net/ethernet/alacritech/Kconfig @@ -0,0 +1,28 @@ +config NET_VENDOR_ALACRITECH +bool "Alacritech devices" +default y +---help--- + If you have a network (Ethernet) card belonging to this class, say Y. + + 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_ALACRITECH + +config SLICOSS + tristate "Alacritech Slicoss support" + depends on PCI + select CRC32 + ---help--- + This driver supports Gigabit Ethernet adapters based on the + Session Layer Interface (SLIC) technology by Alacritech. + + Supported are Mojave (1 port) and Oasis (1, 2 and 4 port) cards, + both copper and fiber. + + To compile this driver as a module, choose M here: the module + will be called slicoss. This is recommended. + +endif # NET_VENDOR_ALACRITECH diff --git a/drivers/net/ethernet/alacritech/Makefile b/drivers/net/ethernet/alacritech/Makefile new file mode 100644 index 000..8790e9e --- /dev/null +++ b/drivers/net/ethernet/alacritech/Makefile @@ -0,0 +1,4 @@ +# +# Makefile for the Alacritech Slicoss driver +# +obj-$(CONFIG_SLICOSS) += slicoss.o diff --git a/drivers/net/ethernet/alacritech/slic.h b/drivers/net/ethernet/alacritech/slic.h new file mode 100644 index 000..c62d46b --- /dev/null +++ b/drivers/net/ethernet/alacritech/slic.h @@ -0,0 +1,576 @@ + +#ifndef _SLIC_H +#define _SLIC_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SLIC_VGBSTAT_XPERR 0x4000 +#define SLIC_VGBSTAT_XERRSHFT 25 +#define SLIC_VGBSTAT_XCSERR0x23 +#define SLIC_VGBSTAT_XUFLOW0x22 +#define SLIC_VGBSTAT_XHLEN 0x20 +#define SLIC_VGBSTAT_NETERR0x0100 +#define SLIC_VGBSTAT_NERRSHFT 16 +#define SLIC_VGBSTAT_NERRMSK 0x1ff +#define SLIC_VGBSTAT_NCSERR0x103 +#define SLIC_VGBSTAT_NUFLOW0x102 +#define SLIC_VGBSTAT_NHLEN 0x100 +#define SLIC_VGBSTAT_LNKERR0x0080 +#define SLIC_VGBSTAT_LERRMSK 0xff +#define SLIC_VGBSTAT_LDEARLY 0x86 +#define SLIC_VGBSTAT_LBOFLO0x85 +#define SLIC_VGBSTAT_LCODERR 0x84 +#define SLIC_VGBSTAT_LDBLNBL 0x83 +#define SLIC_VGBSTAT_LCRCERR
Gigabit ethernet driver for Alacritechs SLIC devices (v3)
Hi, this is the third version of the slicoss gigabit ethernet driver (which is a rework of the driver from Alacritech which can currently be found under drivers/staging/slicoss). The driver is supposed to support Mojave, Oasis and Kalahari cards, for both copper and fiber. If this code is accepted the staging version can be removed. The driver has been tested on a SEN2104ET adapter (4 Port PCIe copper). v3: - dont add defines to pci.h but instead put it into the drivers header file (requested by Greg Kroah-Hartman) v2: - remove unusual padding in statistic strings (suggested by Andrew Lunn) - for mdio register and bit names use defines from mii.h instead of own ones (suggested by Andrew Lunn) - remove unused defines - ensure PCI flush at two more places - use mmiowb before lock to prevent mmio writes leaking out of lock - fix some typos in comments - add copyright and GPL header Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Aw: Re: [PATCH v2 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi, > > On Fri, Nov 25, 2016 at 12:13:04AM +0100, Lino Sanfilippo wrote: > > --- a/include/linux/pci_ids.h > > +++ b/include/linux/pci_ids.h > > @@ -2015,6 +2015,24 @@ > > #define PCI_SUBDEVICE_ID_CCD_OV4S 0xE888 > > #define PCI_SUBDEVICE_ID_CCD_OV8S 0xE998 > > > > +#define PCI_VENDOR_ID_ALACRITECH 0x139A > > +#define PCI_DEVICE_ID_ALACRITECH_MOAVE 0x0005 > > > > Please read the top of this file for why you should not need to ever > modify this file again :) > Youre right, I totally overlooked the comment. Will fix this in the next version, thanks! Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Add driver for Alacritech gigabit ethernet cards with SLIC (session-layer interface control) technology. The driver provides basic support without SLIC for the following devices: - Mojave cards (single port PCI Gigabit) both copper and fiber - Oasis cards (single and dual port PCI-x Gigabit) copper and fiber - Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber Signed-off-by: Lino Sanfilippo --- drivers/net/ethernet/Kconfig |1 + drivers/net/ethernet/Makefile |1 + drivers/net/ethernet/alacritech/Kconfig | 28 + drivers/net/ethernet/alacritech/Makefile |4 + drivers/net/ethernet/alacritech/slic.h| 558 + drivers/net/ethernet/alacritech/slicoss.c | 1867 + include/linux/pci_ids.h | 18 + 7 files changed, 2477 insertions(+) create mode 100644 drivers/net/ethernet/alacritech/Kconfig create mode 100644 drivers/net/ethernet/alacritech/Makefile create mode 100644 drivers/net/ethernet/alacritech/slic.h create mode 100644 drivers/net/ethernet/alacritech/slicoss.c diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index 2ffd634..a4cc87fe 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -21,6 +21,7 @@ source "drivers/net/ethernet/3com/Kconfig" source "drivers/net/ethernet/adaptec/Kconfig" source "drivers/net/ethernet/aeroflex/Kconfig" source "drivers/net/ethernet/agere/Kconfig" +source "drivers/net/ethernet/alacritech/Kconfig" source "drivers/net/ethernet/allwinner/Kconfig" source "drivers/net/ethernet/alteon/Kconfig" source "drivers/net/ethernet/altera/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 1d349e9..b448027 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_NET_VENDOR_8390) += 8390/ obj-$(CONFIG_NET_VENDOR_ADAPTEC) += adaptec/ obj-$(CONFIG_GRETH) += aeroflex/ obj-$(CONFIG_NET_VENDOR_AGERE) += agere/ +obj-$(CONFIG_NET_VENDOR_ALACRITECH) += alacritech/ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/ obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ obj-$(CONFIG_ALTERA_TSE) += altera/ diff --git a/drivers/net/ethernet/alacritech/Kconfig b/drivers/net/ethernet/alacritech/Kconfig new file mode 100644 index 000..41000a3 --- /dev/null +++ b/drivers/net/ethernet/alacritech/Kconfig @@ -0,0 +1,28 @@ +config NET_VENDOR_ALACRITECH +bool "Alacritech devices" +default y +---help--- + If you have a network (Ethernet) card belonging to this class, say Y. + + 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_ALACRITECH + +config SLICOSS + tristate "Alacritech Slicoss support" + depends on PCI + select CRC32 + ---help--- + This driver supports Gigabit Ethernet adapters based on the + Session Layer Interface (SLIC) technology by Alacritech. + + Supported are Mojave (1 port) and Oasis (1, 2 and 4 port) cards, + both copper and fiber. + + To compile this driver as a module, choose M here: the module + will be called slicoss. This is recommended. + +endif # NET_VENDOR_ALACRITECH diff --git a/drivers/net/ethernet/alacritech/Makefile b/drivers/net/ethernet/alacritech/Makefile new file mode 100644 index 000..8790e9e --- /dev/null +++ b/drivers/net/ethernet/alacritech/Makefile @@ -0,0 +1,4 @@ +# +# Makefile for the Alacritech Slicoss driver +# +obj-$(CONFIG_SLICOSS) += slicoss.o diff --git a/drivers/net/ethernet/alacritech/slic.h b/drivers/net/ethernet/alacritech/slic.h new file mode 100644 index 000..cea5751 --- /dev/null +++ b/drivers/net/ethernet/alacritech/slic.h @@ -0,0 +1,558 @@ + +#ifndef _SLIC_H +#define _SLIC_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SLIC_VGBSTAT_XPERR 0x4000 +#define SLIC_VGBSTAT_XERRSHFT 25 +#define SLIC_VGBSTAT_XCSERR0x23 +#define SLIC_VGBSTAT_XUFLOW0x22 +#define SLIC_VGBSTAT_XHLEN 0x20 +#define SLIC_VGBSTAT_NETERR0x0100 +#define SLIC_VGBSTAT_NERRSHFT 16 +#define SLIC_VGBSTAT_NERRMSK 0x1ff +#define SLIC_VGBSTAT_NCSERR0x103 +#define SLIC_VGBSTAT_NUFLOW0x102 +#define SLIC_VGBSTAT_NHLEN 0x100 +#define SLIC_VGBSTAT_LNKERR0x0080 +#define SLIC_VGBSTAT_LERRMSK 0xff +#define SLIC_VGBSTAT_LDEARLY 0x86 +#define SLIC_VGBSTAT_LBOFLO0x85 +#define SLIC_VGBSTAT_LCODERR 0x84 +#define SLIC_VGBSTAT_LDBLNBL
Gigabit ethernet driver for Alacritechs SLIC devices
Hi, this is the second version of the slicoss gigabit ethernet driver (which is a rework of the driver from Alacritech which can currently be found under drivers/staging/slicoss). The driver is supposed to support Mojave, Oasis and Kalahari cards, for both copper and fiber. If this code is accepted the staging version can be removed. The driver has been tested on a SEN2104ET adapter (4 Port PCIe copper). v2: - remove unusual padding in statistic strings (suggested by Andrew Lunn) - for mdio register and bit names use defines from mii.h instead of own ones (suggested by Andrew Lunn) - remove unused defines - ensure PCI flush at two more places - use mmiowb before lock to prevent mmio writes leaking out of lock - fix some typos in comments - add copyright and GPL header Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 net-next 2/2] MAINTAINERS: add entry for slicoss ethernet driver
Add myself as maintainer for the slicoss ethernet driver. Signed-off-by: Lino Sanfilippo --- MAINTAINERS | 5 + 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6781a3f..bb9af28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -562,6 +562,11 @@ T: git git://linuxtv.org/anttip/media_tree.git S: Maintained F: drivers/media/usb/airspy/ +ALACRITECH GIGABIT ETHERNET DRIVER +M: Lino Sanfilippo +S: Maintained +F: drivers/net/ethernet/alacritech/* + ALCATEL SPEEDTOUCH USB DRIVER M: Duncan Sands L: linux-...@vger.kernel.org -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Aw: Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi Andrew, Hi Florian > Gesendet: Dienstag, 15. November 2016 um 23:34 Uhr > Von: "Lino Sanfilippo" > An: "Andrew Lunn" > Cc: "Florian Fainelli" , da...@davemloft.net, > char...@alacritech.com, lio...@gmail.com, gre...@linuxfoundation.org, > de...@driverdev.osuosl.org, linux-ker...@vger.kernel.org, > net...@vger.kernel.org > Betreff: Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit > ethernet driver > > On 15.11.2016 22:59, Andrew Lunn wrote: > >> The link state is retrieved by a command to the application processor that > >> is running > >> on the network card. Also the register to set the phy configuration is > >> write-only, so > >> it is not even possible to do the usual mdio bit-banging in the Phy read() > >> and write() > >> functions (however there seems to be another application processor command > >> reserved > >> for retrieving the PHY settings, but I have not tried it yet). > > > >>> + val = MII_BMCR << 16 | SLIC_PCR_AUTONEG | > >>> + SLIC_PCR_AUTONEG_RST; > >>> + slic_write(sdev, SLIC_REG_WPHY, val); > > > > This actually looks a lot like an MDIO write operation. The upper 16 > > bits are the register, and the lower 16 bits are the data. What you > > don't have is the address. But maybe it is limited to one address. > > > > If the processor command reserved for read works in a similar way, you > > have enough to do an MDIO bus. > > > > Ok, I will give it a try. Reading values via the application processor > is a bit awkward though, since it requires an address to a dma area as part of > the command and then the AP informs the driver via irq that the dma memory > has > been written. So probably the irq handler will have to set some flag and > the mdio_read() function will have to poll for that flag in place of doing > bit-banging a register. > > > If you can get the read working look at registers 2 and 3. Compare > > what you get with the values at the end of marvell.c. > > > > Will do, thank you! > unfortunately I was not able to figure out how to read the phy. My hope was to find a hidden register that I can use to request the phy status from the cards utility processor. I actually found two more registers that seem to be reserved for the communication with the UP. At least they cause the UPR irq to be fired but there is no data written to the provided dma address. I assume that they are not meant to be used for the this purpose. So I am afraid I am not able to use the phy API in this driver for now. However I will send a v2 of the driver shortly that will include the other changes suggested by Andrew along with some further small improvements. Thanks for your help so far! Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
On 16.11.2016 00:03, Andrew Lunn wrote: >> > + val = MII_BMCR << 16 | SLIC_PCR_AUTONEG | >> > + SLIC_PCR_AUTONEG_RST; >> > + slic_write(sdev, SLIC_REG_WPHY, val); > >> Thats essentially what I meant by setting a flag in the irq handler. The mdio >> function would have to check somehow if the irq has been fired (be it by >> means >> of a flag or a completion that is set by the irq handler and checked by the >> mdio function). So I agree that it should work (if reading via the AP command >> is actually possible). > > It seems odd you have a nice simple way to do writes, but reads are > very complex. There might be a simple read method hiding somewhere. > > Andrew > I agree, it IS odd :). But concerning reading the phy this is all I can see in the original source code: http://lxr.free-electrons.com/source/drivers/staging/slicoss/slichw.h#L516 I strongly suspect that "RPHY" stand for "read phy". The only one who may know for sure if there is another/better way is Christopher Harrer. He is also on CC but I am not sure if he actually follows this discussion. Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
On 15.11.2016 23:39, Florian Fainelli wrote: > On 11/15/2016 02:34 PM, Lino Sanfilippo wrote: >> On 15.11.2016 22:59, Andrew Lunn wrote: >>>> The link state is retrieved by a command to the application processor that >>>> is running >>>> on the network card. Also the register to set the phy configuration is >>>> write-only, so >>>> it is not even possible to do the usual mdio bit-banging in the Phy read() >>>> and write() >>>> functions (however there seems to be another application processor command >>>> reserved >>>> for retrieving the PHY settings, but I have not tried it yet). >>> >>>>> + val = MII_BMCR << 16 | SLIC_PCR_AUTONEG | >>>>> + SLIC_PCR_AUTONEG_RST; >>>>> + slic_write(sdev, SLIC_REG_WPHY, val); >>> >>> This actually looks a lot like an MDIO write operation. The upper 16 >>> bits are the register, and the lower 16 bits are the data. What you >>> don't have is the address. But maybe it is limited to one address. >>> >>> If the processor command reserved for read works in a similar way, you >>> have enough to do an MDIO bus. >>> >> >> Ok, I will give it a try. Reading values via the application processor >> is a bit awkward though, since it requires an address to a dma area as part >> of >> the command and then the AP informs the driver via irq that the dma memory >> has >> been written. So probably the irq handler will have to set some flag and >> the mdio_read() function will have to poll for that flag in place of doing >> bit-banging a register. > > That's a bit unusual compared to typical controllers that are usually > memory-mapped and that you can either write to, read/poll to know about > completion. I suppose that you could still have a mdiobus implementation > that is able to read to/from PHYs by submitting a command to the AP, > wait on a completion structure, and have the interrupt handler do the > completion of the command? > Thats essentially what I meant by setting a flag in the irq handler. The mdio function would have to check somehow if the irq has been fired (be it by means of a flag or a completion that is set by the irq handler and checked by the mdio function). So I agree that it should work (if reading via the AP command is actually possible). Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
On 15.11.2016 22:59, Andrew Lunn wrote: >> The link state is retrieved by a command to the application processor that >> is running >> on the network card. Also the register to set the phy configuration is >> write-only, so >> it is not even possible to do the usual mdio bit-banging in the Phy read() >> and write() >> functions (however there seems to be another application processor command >> reserved >> for retrieving the PHY settings, but I have not tried it yet). > >>> + val = MII_BMCR << 16 | SLIC_PCR_AUTONEG | >>> +SLIC_PCR_AUTONEG_RST; >>> + slic_write(sdev, SLIC_REG_WPHY, val); > > This actually looks a lot like an MDIO write operation. The upper 16 > bits are the register, and the lower 16 bits are the data. What you > don't have is the address. But maybe it is limited to one address. > > If the processor command reserved for read works in a similar way, you > have enough to do an MDIO bus. > Ok, I will give it a try. Reading values via the application processor is a bit awkward though, since it requires an address to a dma area as part of the command and then the AP informs the driver via irq that the dma memory has been written. So probably the irq handler will have to set some flag and the mdio_read() function will have to poll for that flag in place of doing bit-banging a register. > If you can get the read working look at registers 2 and 3. Compare > what you get with the values at the end of marvell.c. > Will do, thank you! Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi, On 15.11.2016 21:54, Florian Fainelli wrote: > On 11/15/2016 12:46 PM, Lino Sanfilippo wrote: >>> Could this be pulled out into a standard PHY driver? All the SLIC >>> SLIC_PCR_ defines seems to be the same as those in mii.h. This could >>> be a standard PHY hidden behind a single register. >>> >>>Andrew >> >> You are right, the driver should really use the defines in mii.h. I will fix >> this in >> a v2. >> >> Concerning the use of the PHY API: What would be the advantage of using it? >> Note that the >> phy is always internal and not interchangeable. Is not the >> interchangeability of PHYs >> the main reason for using this API? > > Not reinventing the wheel primarily, while PHYLIB also solves the plug & > play aspect of external PHYs, it also solves the basic link management, > and consistent and reasonably well defined interface to user-space and > drivers (statistics reporting, link, auto-negotiation, EEE etc.). > Sure I see this point. But currently all the driver does concerning the phy is to configure it for auto negotiation when the interface is brought up, nothing else. The link state is retrieved by a command to the application processor that is running on the network card. Also the register to set the phy configuration is write-only, so it is not even possible to do the usual mdio bit-banging in the Phy read() and write() functions (however there seems to be another application processor command reserved for retrieving the PHY settings, but I have not tried it yet). Please also note that I do not have any datasheets or other documentation for the hardware, all I have as a reference is the driver code in staging. So I do not know which PHYs are actually used (the comments in the code mention Marvell and Cicada but this is not very specific). Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Hi, On 13.11.2016 20:55, Andrew Lunn wrote: >> +static const char slic_stats_strings[][ETH_GSTRING_LEN] = { >> +"rx_packets ", >> +"rx_bytes ", >> +"rx_multicasts ", >> +"rx_errors ", >> +"rx_buff_miss ", >> +"rx_tp_csum ", >> +"rx_tp_oflow", >> +"rx_tp_hlen ", >> +"rx_ip_csum ", >> +"rx_ip_len ", > > Are there any other drivers which pad the statistics strings? > First off, thank you for the review! I took a look into a few drivers and most of them do not pad the statistic strings. Actually there are some that do (e.g. the chelsio drivers cxgb4, cxgb3, xcgb4v), but this seems to be rather the minority, so I will remove it. Thank you for the hint. >> +static void slic_set_link_autoneg(struct slic_device *sdev) >> +{ >> +unsigned int subid = sdev->pdev->subsystem_device; >> +u32 val; >> + >> +if (sdev->is_fiber) { >> +/* We've got a fiber gigabit interface, and register 4 is >> + * different in fiber mode than in copper mode. >> + */ >> +/* advertise FD only @1000 Mb */ >> +val = MII_ADVERTISE << 16 | SLIC_PAR_ADV1000XFD | >> + SLIC_PAR_ASYMPAUSE_FIBER; >> +/* enable PAUSE frames */ >> +slic_write(sdev, SLIC_REG_WPHY, val); >> +/* reset phy, enable auto-neg */ >> +val = MII_BMCR << 16 | SLIC_PCR_RESET | SLIC_PCR_AUTONEG | >> + SLIC_PCR_AUTONEG_RST; >> +slic_write(sdev, SLIC_REG_WPHY, val); >> +} else {/* copper gigabit */ >> +/* We've got a copper gigabit interface, and register 4 is >> + * different in copper mode than in fiber mode. >> + */ >> +/* advertise 10/100 Mb modes */ >> +val = MII_ADVERTISE << 16 | SLIC_PAR_ADV100FD | >> + SLIC_PAR_ADV100HD | SLIC_PAR_ADV10FD | SLIC_PAR_ADV10HD; >> +/* enable PAUSE frames */ >> +val |= SLIC_PAR_ASYMPAUSE; >> +/* required by the Cicada PHY */ >> +val |= SLIC_PAR_802_3; >> +slic_write(sdev, SLIC_REG_WPHY, val); >> + >> +/* advertise FD only @1000 Mb */ >> +val = MII_CTRL1000 << 16 | SLIC_PGC_ADV1000FD; >> +slic_write(sdev, SLIC_REG_WPHY, val); >> + >> +if (subid != PCI_SUBDEVICE_ID_ALACRITECH_CICADA) { >> + /* if a Marvell PHY enable auto crossover */ >> +val = SLIC_MIICR_REG_16 | SLIC_MRV_REG16_XOVERON; >> +slic_write(sdev, SLIC_REG_WPHY, val); >> + >> +/* reset phy, enable auto-neg */ >> +val = MII_BMCR << 16 | SLIC_PCR_RESET | >> + SLIC_PCR_AUTONEG | SLIC_PCR_AUTONEG_RST; >> +slic_write(sdev, SLIC_REG_WPHY, val); >> +} else { >> +/* enable and restart auto-neg (don't reset) */ >> +val = MII_BMCR << 16 | SLIC_PCR_AUTONEG | >> + SLIC_PCR_AUTONEG_RST; >> +slic_write(sdev, SLIC_REG_WPHY, val); >> +} >> +} >> +sdev->autoneg = true; >> +} > > Could this be pulled out into a standard PHY driver? All the SLIC > SLIC_PCR_ defines seems to be the same as those in mii.h. This could > be a standard PHY hidden behind a single register. > >Andrew You are right, the driver should really use the defines in mii.h. I will fix this in a v2. Concerning the use of the PHY API: What would be the advantage of using it? Note that the phy is always internal and not interchangeable. Is not the interchangeability of PHYs the main reason for using this API? Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Add driver for Alacritech gigabit ethernet cards with SLIC (session-layer interface control) technology. The driver provides basic support without SLIC for the following devices: - Mojave cards (single port PCI Gigabit) both copper and fiber - Oasis cards (single and dual port PCI-x Gigabit) copper and fiber - Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber Signed-off-by: Lino Sanfilippo --- drivers/net/ethernet/Kconfig |1 + drivers/net/ethernet/Makefile |1 + drivers/net/ethernet/alacritech/Kconfig | 28 + drivers/net/ethernet/alacritech/Makefile |4 + drivers/net/ethernet/alacritech/slic.h| 606 ++ drivers/net/ethernet/alacritech/slicoss.c | 1855 + include/linux/pci_ids.h | 18 + 7 files changed, 2513 insertions(+) create mode 100644 drivers/net/ethernet/alacritech/Kconfig create mode 100644 drivers/net/ethernet/alacritech/Makefile create mode 100644 drivers/net/ethernet/alacritech/slic.h create mode 100644 drivers/net/ethernet/alacritech/slicoss.c diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index 2ffd634..a4cc87fe 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -21,6 +21,7 @@ source "drivers/net/ethernet/3com/Kconfig" source "drivers/net/ethernet/adaptec/Kconfig" source "drivers/net/ethernet/aeroflex/Kconfig" source "drivers/net/ethernet/agere/Kconfig" +source "drivers/net/ethernet/alacritech/Kconfig" source "drivers/net/ethernet/allwinner/Kconfig" source "drivers/net/ethernet/alteon/Kconfig" source "drivers/net/ethernet/altera/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 1d349e9..b448027 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_NET_VENDOR_8390) += 8390/ obj-$(CONFIG_NET_VENDOR_ADAPTEC) += adaptec/ obj-$(CONFIG_GRETH) += aeroflex/ obj-$(CONFIG_NET_VENDOR_AGERE) += agere/ +obj-$(CONFIG_NET_VENDOR_ALACRITECH) += alacritech/ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/ obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ obj-$(CONFIG_ALTERA_TSE) += altera/ diff --git a/drivers/net/ethernet/alacritech/Kconfig b/drivers/net/ethernet/alacritech/Kconfig new file mode 100644 index 000..41000a3 --- /dev/null +++ b/drivers/net/ethernet/alacritech/Kconfig @@ -0,0 +1,28 @@ +config NET_VENDOR_ALACRITECH +bool "Alacritech devices" +default y +---help--- + If you have a network (Ethernet) card belonging to this class, say Y. + + 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_ALACRITECH + +config SLICOSS + tristate "Alacritech Slicoss support" + depends on PCI + select CRC32 + ---help--- + This driver supports Gigabit Ethernet adapters based on the + Session Layer Interface (SLIC) technology by Alacritech. + + Supported are Mojave (1 port) and Oasis (1, 2 and 4 port) cards, + both copper and fiber. + + To compile this driver as a module, choose M here: the module + will be called slicoss. This is recommended. + +endif # NET_VENDOR_ALACRITECH diff --git a/drivers/net/ethernet/alacritech/Makefile b/drivers/net/ethernet/alacritech/Makefile new file mode 100644 index 000..8790e9e --- /dev/null +++ b/drivers/net/ethernet/alacritech/Makefile @@ -0,0 +1,4 @@ +# +# Makefile for the Alacritech Slicoss driver +# +obj-$(CONFIG_SLICOSS) += slicoss.o diff --git a/drivers/net/ethernet/alacritech/slic.h b/drivers/net/ethernet/alacritech/slic.h new file mode 100644 index 000..963a20d --- /dev/null +++ b/drivers/net/ethernet/alacritech/slic.h @@ -0,0 +1,606 @@ + +#ifndef _SLIC_H +#define _SLIC_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SLIC_VGBSTAT_XPERR 0x4000 +#define SLIC_VGBSTAT_XERRSHFT 25 +#define SLIC_VGBSTAT_XCSERR0x23 +#define SLIC_VGBSTAT_XUFLOW0x22 +#define SLIC_VGBSTAT_XHLEN 0x20 +#define SLIC_VGBSTAT_NETERR0x0100 +#define SLIC_VGBSTAT_NERRSHFT 16 +#define SLIC_VGBSTAT_NERRMSK 0x1ff +#define SLIC_VGBSTAT_NCSERR0x103 +#define SLIC_VGBSTAT_NUFLOW0x102 +#define SLIC_VGBSTAT_NHLEN 0x100 +#define SLIC_VGBSTAT_LNKERR0x0080 +#define SLIC_VGBSTAT_LERRMSK 0xff +#define SLIC_VGBSTAT_LDEARLY 0x86 +#define SLIC_VGBSTAT_LBOFLO0x85 +#define SLIC_VGBSTAT_LCODERR 0x84 +#define SLIC_VGBSTAT_LDBLNBL
[net-next 2/2] MAINTAINERS: add entry for slicoss ethernet driver
Add myself as maintainer for the slicoss ethernet driver. Signed-off-by: Lino Sanfilippo --- MAINTAINERS | 5 + 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6781a3f..bb9af28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -562,6 +562,11 @@ T: git git://linuxtv.org/anttip/media_tree.git S: Maintained F: drivers/media/usb/airspy/ +ALACRITECH GIGABIT ETHERNET DRIVER +M: Lino Sanfilippo +S: Maintained +F: drivers/net/ethernet/alacritech/* + ALCATEL SPEEDTOUCH USB DRIVER M: Duncan Sands L: linux-...@vger.kernel.org -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Gigabit ethernet driver for Alacritechs SLIC devices
Hi, this is a rework of the slicoss gigabit ethernet driver from Alacritech that is currently part of the staging area. The driver is supposed to support Mojave, Oasis and Kalahari cards, for both copper and fiber. If this code is accepted the staging version can be removed (as Greg told me by email, he would do this himself so this is not part of these patches). The driver is tested on a SEN2104ET card (4 Port PCIe copper). Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: slicoss: replace memcpy_fromio with memcpy
On 18.10.2016 23:26, Ryan Swan wrote: > As per discusion with Lino Sanfilippo, memcpy is the proper way to copy > across dma memory, which also removes sparse warning that triggered > inquiry. > > Signed-off-by: Ryan Swan > --- > drivers/staging/slicoss/slicoss.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/slicoss/slicoss.c > b/drivers/staging/slicoss/slicoss.c > index 2802b90..9a1dc72 100644 > --- a/drivers/staging/slicoss/slicoss.c > +++ b/drivers/staging/slicoss/slicoss.c > @@ -1057,7 +1057,7 @@ static void slic_upr_request_complete(struct adapter > *adapter, u32 isr) > if (stats->rcv_drops > old->rcv_drops) > adapter->rcv_drops += (stats->rcv_drops - > old->rcv_drops); > - memcpy_fromio(old, stats, sizeof(*stats)); > + memcpy(old, stats, sizeof(*stats)); > break; > } > case SLIC_UPR_RLSR: > Reviewed-by: Lino Sanfilippo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: slicoss.ko: slicoss.c: Fixed incorrect argument type
Hi Ryan, On 18.10.2016 20:03, Ryan Swan wrote: > sparse produced > warning: incorrect type in argument 2 (different address spaces) > expected void const volatile [noderef] *src > got struct slic_stats *stats > > casting argument 2 to what is expected by memcpy_fromio() fixed this > > Signed-off-by: Ryan Swan > --- > drivers/staging/slicoss/slicoss.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/slicoss/slicoss.c > b/drivers/staging/slicoss/slicoss.c > index 2802b90..7c6feb1 100644 > --- a/drivers/staging/slicoss/slicoss.c > +++ b/drivers/staging/slicoss/slicoss.c > @@ -1057,7 +1057,7 @@ static void slic_upr_request_complete(struct adapter > *adapter, u32 isr) > if (stats->rcv_drops > old->rcv_drops) > adapter->rcv_drops += (stats->rcv_drops - > old->rcv_drops); > - memcpy_fromio(old, stats, sizeof(*stats)); > + memcpy_fromio(old, (void __iomem *)stats, sizeof(*stats)); > break; > } > case SLIC_UPR_RLSR: > The issue here is the use of memcpy_fromio() while it actually is not io but dma memory that we copy from. Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Aw: Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
> Gesendet: Dienstag, 26. Juli 2016 um 08:25 Uhr > Von: "SF Markus Elfring" > > >> - if (strncasecmp(buff, "RSSI", length) == 0) { > >> + if (strncasecmp(buff, "RSSI", 0) == 0) { > >> + s8 rssi; > >> + > > > > Um, please think a second about if it makes any sense at all to compare > > zero chars of two strings. > > Under which circumstances should the variable "length" contain an other > value than zero? Which circumstances do "not any sense at all" imply? > > How can this open issue be fixed better? The code is not too complicated and I think it is very obvious which value/variable should be passed instead of 0. I suggest to fix this since it is indeed a bug, instead of doing "micro optimizations" - which is the last thing that code in the staging area needs (as IIRC you have already been told by others, including the staging maintainer). Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/9] staging: slicoss: handle allocation failure in slic_init_adapter
The memory allocation in slic_init_adapter() can fail. Return an error in this case and unwind properly. Also make sure that the allocated memory is properly freed in case of an error in the calling probe() function. By doing this also replace the alloc() followed by memset to zero the memory with a zalloc() version. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index ac126d4..dae07410 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2896,10 +2896,10 @@ static void slic_init_driver(void) } } -static void slic_init_adapter(struct net_device *netdev, - struct pci_dev *pcidev, - const struct pci_device_id *pci_tbl_entry, - void __iomem *memaddr, int chip_idx) +static int slic_init_adapter(struct net_device *netdev, +struct pci_dev *pcidev, +const struct pci_device_id *pci_tbl_entry, +void __iomem *memaddr, int chip_idx) { ushort index; struct slic_handle *pslic_handle; @@ -2938,13 +2938,13 @@ static void slic_init_adapter(struct net_device *netdev, pslic_handle->next = adapter->pfree_slic_handles; adapter->pfree_slic_handles = pslic_handle; } - adapter->pshmem = (struct slic_shmem *) - pci_alloc_consistent(adapter->pcidev, - sizeof(struct slic_shmem), - &adapter-> - phys_shmem); - if (adapter->pshmem) - memset(adapter->pshmem, 0, sizeof(struct slic_shmem)); + adapter->pshmem = pci_zalloc_consistent(adapter->pcidev, + sizeof(struct slic_shmem), + &adapter->phys_shmem); + if (!adapter->pshmem) + return -ENOMEM; + + return 0; } static const struct net_device_ops slic_netdev_ops = { @@ -3142,13 +3142,17 @@ static int slic_entry_probe(struct pci_dev *pcidev, slic_init_driver(); - slic_init_adapter(netdev, - pcidev, pci_tbl_entry, memmapped_ioaddr, cards_found); + err = slic_init_adapter(netdev, pcidev, pci_tbl_entry, memmapped_ioaddr, + cards_found); + if (err) { + dev_err(&pcidev->dev, "failed to init adapter: %i\n", err); + goto err_out_unmap; + } err = slic_card_locate(adapter); if (err) { dev_err(&pcidev->dev, "cannot locate card\n"); - goto err_out_unmap; + goto err_clean_init; } card = adapter->card; @@ -3160,7 +3164,7 @@ static int slic_entry_probe(struct pci_dev *pcidev, err = slic_card_init(card, adapter); if (err) - goto err_out_unmap; + goto err_clean_init; slic_adapter_set_hwaddr(adapter); @@ -3172,13 +3176,15 @@ static int slic_entry_probe(struct pci_dev *pcidev, err = register_netdev(netdev); if (err) { dev_err(&pcidev->dev, "Cannot register net device, aborting.\n"); - goto err_out_unmap; + goto err_clean_init; } cards_found++; return 0; +err_clean_init: + slic_init_cleanup(adapter); err_out_unmap: iounmap(memmapped_ioaddr); err_out_free_netdev: -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/9] staging: slicoss: start tx queue when interface is brought up
There is no reason to delay tx queue activation until a link is detected. So start the queue when the interface is brought up and stop it when the interface is brought down. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 4dba080..577c2d2 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1028,7 +1028,6 @@ static void slic_link_upr_complete(struct adapter *adapter, u32 isr) /* setup the mac */ slic_config_set(adapter, true); adapter->linkstate = LINK_UP; - netif_start_queue(adapter->netdev); netif_carrier_on(adapter->netdev); } } @@ -2419,7 +2418,6 @@ static int slic_entry_open(struct net_device *dev) unsigned long flags; int status; - netif_stop_queue(adapter->netdev); netif_carrier_off(dev); spin_lock_irqsave(&slic_global.driver_lock, flags); @@ -2443,6 +2441,9 @@ static int slic_entry_open(struct net_device *dev) spin_unlock: spin_unlock_irqrestore(&slic_global.driver_lock, flags); + + netif_start_queue(adapter->netdev); + return status; } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/9] staging: slicoss: notifiy network stack about change in link state
Notify the network stack about link states via netif_carrier_[off|on](). Also set the link state off initially and when the interface is brought down. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index dae07410..a9323a9 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1016,6 +1016,7 @@ static void slic_link_upr_complete(struct adapter *adapter, u32 isr) /* link has gone from up to down */ if (linkup == LINK_DOWN) { adapter->linkstate = LINK_DOWN; + netif_carrier_off(adapter->netdev); return; } @@ -1028,6 +1029,7 @@ static void slic_link_upr_complete(struct adapter *adapter, u32 isr) slic_config_set(adapter, true); adapter->linkstate = LINK_UP; netif_start_queue(adapter->netdev); + netif_carrier_on(adapter->netdev); } } @@ -2418,6 +2420,7 @@ static int slic_entry_open(struct net_device *dev) int status; netif_stop_queue(adapter->netdev); + netif_carrier_off(dev); spin_lock_irqsave(&slic_global.driver_lock, flags); if (!adapter->activated) { @@ -2530,6 +2533,9 @@ static int slic_entry_halt(struct net_device *dev) #endif spin_unlock_irqrestore(&slic_global.driver_lock, flags); + + netif_carrier_off(dev); + return 0; } @@ -3172,6 +3178,8 @@ static int slic_entry_probe(struct pci_dev *pcidev, netdev->irq = adapter->irq; netdev->netdev_ops = &slic_netdev_ops; + netif_carrier_off(netdev); + strcpy(netdev->name, "eth%d"); err = register_netdev(netdev); if (err) { -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/9] staging: slicoss: ensure mapping of io-memory is uncached
From: Lino Sanfilippo Writes to registers should be done uncached for various reasons. Ensure this by replacing ioremap() with ioremap_nocache(). Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index a9323a9..4dba080 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -3136,7 +3136,7 @@ static int slic_entry_probe(struct pci_dev *pcidev, mmio_start = pci_resource_start(pcidev, 0); mmio_len = pci_resource_len(pcidev, 0); - memmapped_ioaddr = ioremap(mmio_start, mmio_len); + memmapped_ioaddr = ioremap_nocache(mmio_start, mmio_len); if (!memmapped_ioaddr) { dev_err(&pcidev->dev, "cannot remap MMIO region %lx @ %lx\n", mmio_len, mmio_start); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/9] staging: slicoss: dont use a structure but offsets for register accesses
Use the new register accessors that use offsets instead of the slic_regs structure to read/write registers. Since not longer needed remove the structure completley. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 1 - drivers/staging/slicoss/slichw.h | 219 -- drivers/staging/slicoss/slicoss.c | 323 ++ 3 files changed, 120 insertions(+), 423 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 230d30b..3bba82a 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -417,7 +417,6 @@ struct adapter { struct slic_shmem *pshmem; dma_addr_t phys_shmem; u32 isrcopy; - __iomem struct slic_regs *slic_regs; void __iomem *regs; unsigned char state; unsigned char linkstate; diff --git a/drivers/staging/slicoss/slichw.h b/drivers/staging/slicoss/slichw.h index f06450e..ae04bf6 100644 --- a/drivers/staging/slicoss/slichw.h +++ b/drivers/staging/slicoss/slichw.h @@ -402,225 +402,6 @@ struct slic_rspbuf { #define SLIC_REG_HOSTID0x1554 -struct slic_regs { - u32 slic_reset; /* Reset Register */ - u32 pad0; - - u32 slic_icr; /* Interrupt Control Register */ - u32 pad2; -#define SLIC_ICR 0x0008 - - u32 slic_isp; /* Interrupt status pointer */ - u32 pad1; -#define SLIC_ISP 0x0010 - - u32 slic_isr; /* Interrupt status */ - u32 pad3; -#define SLIC_ISR 0x0018 - - u32 slic_hbar; /* Header buffer address reg */ - u32 pad4; - /* -* 31-8 - phy addr of set of contiguous hdr buffers -* 7-0 - number of buffers passed -* Buffers are 256 bytes long on 256-byte boundaries. -*/ -#define SLIC_HBAR 0x0020 -#define SLIC_HBAR_CNT_MSK 0x00FF - - u32 slic_dbar; /* Data buffer handle & address reg */ - u32 pad5; - - /* 4 sets of registers; Buffers are 2K bytes long 2 per 4K page. */ -#define SLIC_DBAR 0x0028 -#define SLIC_DBAR_SIZE 2048 - - u32 slic_cbar; /* Xmt Cmd buf addr regs.*/ - /* -* 1 per XMT interface -* 31-5 - phy addr of host command buffer -* 4-0 - length of cmd in multiples of 32 bytes -* Buffers are 32 bytes up to 512 bytes long -*/ -#define SLIC_CBAR 0x0030 -#define SLIC_CBAR_LEN_MSK 0x001F -#define SLIC_CBAR_ALIGN0x0020 - - u32 slic_wcs; /* write control store*/ -#defineSLIC_WCS0x0034 -#define SLIC_WCS_START 0x8000 /*Start the SLIC (Jump to WCS)*/ -#define SLIC_WCS_COMPARE 0x4000 /* Compare with value in WCS*/ - - u32 slic_rbar; /* Response buffer address reg.*/ - u32 pad7; - /* -* 31-8 - phy addr of set of contiguous response buffers -* 7-0 - number of buffers passed -* Buffers are 32 bytes long on 32-byte boundaries. -*/ -#define SLIC_RBAR 0x0038 -#define SLIC_RBAR_CNT_MSK 0x00FF -#define SLIC_RBAR_SIZE 32 - - u32 slic_stats; /* read statistics (UPR) */ - u32 pad8; -#defineSLIC_RSTAT 0x0040 - - u32 slic_rlsr; /* read link status */ - u32 pad9; -#define SLIC_LSTAT 0x0048 - - u32 slic_wmcfg; /* Write Mac Config */ - u32 pad10; -#defineSLIC_WMCFG 0x0050 - - u32 slic_wphy; /* Write phy register */ - u32 pad11; -#define SLIC_WPHY 0x0058 - - u32 slic_rcbar; /* Rcv Cmd buf addr reg */ - u32 pad12; -#defineSLIC_RCBAR 0x0060 - - u32 slic_rconfig; /* Read SLIC Config*/ - u32 pad13; -#define SLIC_RCONFIG 0x0068 - - u32 slic_intagg;/* Interrupt aggregation time */ - u32 pad14; -#define SLIC_INTAGG0x0070 - - u32 slic_wxcfg; /* Write XMIT config reg*/ - u32 pad16; -#defineSLIC_WXCFG 0x0078 - - u32 slic_wrcfg; /* Write RCV config reg*/ - u32 pad17; -#defineSLIC_WRCFG 0x0080 - - u32 slic_wraddral; /* Write rcv addr a low*/ - u32 pad18; -#defineSLIC_WRADDRAL 0x0088 - - u32 slic_wraddrah; /* Write rcv addr a high*/ - u32 pad19; -#defineSLIC_WRADDRAH 0x0090 - - u32 slic_wraddrbl; /* Write rcv addr b low*/ - u32 pad20; -#defineSLIC_WRADDRBL 0x0098 - - u32 slic_wraddrbh; /* Write rcv addr b high*/ - u32 pad21; -#defineSLIC_WRAD
Slicoss fixes and improvements
Hi, this patch series tries to get the slicoss driver code closer to a state in which it is ready to be moved out of staging. Patch 1 is a resend of patch I sent a week ago and handles an allocation failure in slic_init_adapter(). Patch 2 fixes link state notification. Patch 3 turns the mapping for the io area from cached to uncached. Patch 4 remove the delay of tx queue start until a link is detected. Patch 5 introduces register accessor functions that use register offsets. This is in preparation to replace the register addressing by means of the slic_regs struct with an addressing by means of offsets. This is one of the tasks listed in the TODO file. Patch 6 introduces a slic_flush_write() function and handles issues that could result form pci write posting. Patch 7 completes the task started with patch 5 Patch 8 improves the implementation around the shared memory chunk used for isr, status and link. It removes the volatile specifier from the slic_shmem structure which is also listed in the TODO file. Patch 9 also addresses a TODO by merging the structures for statistics and thereby removing some unions. The patches have been tested with an Alacritech SEN2104ET PCI-E (4 Port) adapter. Regards, Lino [PATCH 1/9] staging: slicoss: handle allocation failure in [PATCH 2/9] staging: slicoss: notifiy network stack about change in [PATCH 3/9] staging: slicoss: ensure mapping of io-memory is uncached [PATCH 4/9] staging: slicoss: start tx queue when interface is [PATCH 5/9] staging: slicoss: introduce register accessors that use [PATCH 6/9] staging: slicoss: avoid PCI write posting [PATCH 7/9] staging: slicoss: dont use a structure but offsets for [PATCH 8/9] staging: slicoss: improve implementation concerning the [PATCH 9/9] staging: slicoss: simplify struct for statistics ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 9/9] staging: slicoss: simplify struct for statistics
Merge several structures for statistics to one structure and remove unnecessary union nesting. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 18 + drivers/staging/slicoss/slichw.h | 79 --- drivers/staging/slicoss/slicoss.c | 70 ++ 3 files changed, 47 insertions(+), 120 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 4ac1fd2..fe1d2ce 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -351,6 +351,24 @@ struct base_driver { uint cardnuminuse[SLIC_MAX_CARDS]; }; +struct slic_stats { + /* xmit stats */ + u64 xmit_tcp_bytes; + u64 xmit_tcp_segs; + u64 xmit_bytes; + u64 xmit_collisions; + u64 xmit_unicasts; + u64 xmit_other_error; + u64 xmit_excess_collisions; + /* rcv stats */ + u64 rcv_tcp_bytes; + u64 rcv_tcp_segs; + u64 rcv_bytes; + u64 rcv_unicasts; + u64 rcv_other_error; + u64 rcv_drops; +}; + struct slic_shmem_data { u32 isr; u32 lnkstatus; diff --git a/drivers/staging/slicoss/slichw.h b/drivers/staging/slicoss/slichw.h index ae04bf6..49cb91a 100644 --- a/drivers/staging/slicoss/slichw.h +++ b/drivers/staging/slicoss/slichw.h @@ -459,85 +459,6 @@ struct slic_pnp_capabilities { struct slicpm_wakeup_capabilities wakeup_capabilities; }; -struct xmt_stats { - u32 xmit_tcp_bytes; - u32 xmit_tcp_segs; - u32 xmit_bytes; - u32 xmit_collisions; - u32 xmit_unicasts; - u32 xmit_other_error; - u32 xmit_excess_collisions; -}; - -struct rcv_stats { - u32 rcv_tcp_bytes; - u32 rcv_tcp_segs; - u32 rcv_bytes; - u32 rcv_unicasts; - u32 rcv_other_error; - u32 rcv_drops; -}; - -struct xmt_statsgb { - u64 xmit_tcp_bytes; - u64 xmit_tcp_segs; - u64 xmit_bytes; - u64 xmit_collisions; - u64 xmit_unicasts; - u64 xmit_other_error; - u64 xmit_excess_collisions; -}; - -struct rcv_statsgb { - u64 rcv_tcp_bytes; - u64 rcv_tcp_segs; - u64 rcv_bytes; - u64 rcv_unicasts; - u64 rcv_other_error; - u64 rcv_drops; -}; - -struct slic_stats { - union { - struct { - struct xmt_stats xmt100; - struct rcv_stats rcv100; - } stats_100; - struct { - struct xmt_statsgb xmtGB; - struct rcv_statsgb rcvGB; - } stats_GB; - } u; -}; - -#define xmit_tcp_segs100 u.stats_100.xmt100.xmit_tcp_segs -#define xmit_tcp_bytes100 u.stats_100.xmt100.xmit_tcp_bytes -#define xmit_bytes100 u.stats_100.xmt100.xmit_bytes -#define xmit_collisions100 u.stats_100.xmt100.xmit_collisions -#define xmit_unicasts100 u.stats_100.xmt100.xmit_unicasts -#define xmit_other_error100u.stats_100.xmt100.xmit_other_error -#define xmit_excess_collisions100 u.stats_100.xmt100.xmit_excess_collisions -#define rcv_tcp_segs100u.stats_100.rcv100.rcv_tcp_segs -#define rcv_tcp_bytes100 u.stats_100.rcv100.rcv_tcp_bytes -#define rcv_bytes100 u.stats_100.rcv100.rcv_bytes -#define rcv_unicasts100u.stats_100.rcv100.rcv_unicasts -#define rcv_other_error100 u.stats_100.rcv100.rcv_other_error -#define rcv_drops100 u.stats_100.rcv100.rcv_drops -#define xmit_tcp_segs_gb u.stats_GB.xmtGB.xmit_tcp_segs -#define xmit_tcp_bytes_gb u.stats_GB.xmtGB.xmit_tcp_bytes -#define xmit_bytes_gb u.stats_GB.xmtGB.xmit_bytes -#define xmit_collisions_gb u.stats_GB.xmtGB.xmit_collisions -#define xmit_unicasts_gb u.stats_GB.xmtGB.xmit_unicasts -#define xmit_other_error_gbu.stats_GB.xmtGB.xmit_other_error -#define xmit_excess_collisions_gb u.stats_GB.xmtGB.xmit_excess_collisions - -#define rcv_tcp_segs_gbu.stats_GB.rcvGB.rcv_tcp_segs -#define rcv_tcp_bytes_gb u.stats_GB.rcvGB.rcv_tcp_bytes -#define rcv_bytes_gb u.stats_GB.rcvGB.rcv_bytes -#define rcv_unicasts_gbu.stats_GB.rcvGB.rcv_unicasts -#define rcv_other_error_gb u.stats_GB.rcvGB.rcv_other_error -#define rcv_drops_gb u.stats_GB.rcvGB.rcv_drops - struct slic_config_mac { u8 macaddrA[6]; }; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 9a8c6f9..7834bda 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1015,61 +1015,49 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr) break
[PATCH 8/9] staging: slicoss: improve implementation concerning the shared memory
Remove the volatile specifiers of struct slic_shmem. Furthermore store the bus addresses for the isr pointer, link status and statistics separately and access the upper and lower word of these addresses by means of [lower|upper]_32_bits(). By doing this take the endianness into account. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 18 ++- drivers/staging/slicoss/slicoss.c | 267 ++ 2 files changed, 136 insertions(+), 149 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 3bba82a..4ac1fd2 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -351,10 +351,17 @@ struct base_driver { uint cardnuminuse[SLIC_MAX_CARDS]; }; -struct slic_shmem { - volatile u32 isr; - volatile u32 linkstatus; - volatile struct slic_stats inicstats; +struct slic_shmem_data { + u32 isr; + u32 lnkstatus; + struct slic_stats stats; +}; + +struct slic_shmemory { + dma_addr_t isr_phaddr; + dma_addr_t lnkstatus_phaddr; + dma_addr_t stats_phaddr; + struct slic_shmem_data __iomem *shmem_data; }; struct slic_upr { @@ -414,9 +421,8 @@ struct adapter { u32 intrregistered; uintisp_initialized; uintgennumber; - struct slic_shmem *pshmem; + struct slic_shmemory shmem; dma_addr_t phys_shmem; - u32 isrcopy; void __iomem *regs; unsigned char state; unsigned char linkstate; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 8e978e7..9a8c6f9 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -923,42 +923,34 @@ err_unlock_irq: static void slic_link_upr_complete(struct adapter *adapter, u32 isr) { - u32 linkstatus = adapter->pshmem->linkstatus; + struct slic_shmemory *sm = &adapter->shmem; + struct slic_shmem_data *sm_data = sm->shmem_data; + u32 lst = sm_data->lnkstatus; uint linkup; unsigned char linkspeed; unsigned char linkduplex; if ((isr & ISR_UPCERR) || (isr & ISR_UPCBSY)) { - struct slic_shmem *pshmem; + dma_addr_t phaddr = sm->lnkstatus_phaddr; - pshmem = (struct slic_shmem *)(unsigned long) -adapter->phys_shmem; -#if BITS_PER_LONG == 64 - slic_upr_queue_request(adapter, - SLIC_UPR_RLSR, - SLIC_GET_ADDR_LOW(&pshmem->linkstatus), - SLIC_GET_ADDR_HIGH(&pshmem->linkstatus), + slic_upr_queue_request(adapter, SLIC_UPR_RLSR, + cpu_to_le32(lower_32_bits(phaddr)), + cpu_to_le32(upper_32_bits(phaddr)), 0, 0); -#else - slic_upr_queue_request(adapter, - SLIC_UPR_RLSR, - (u32)&pshmem->linkstatus, - SLIC_GET_ADDR_HIGH(pshmem), 0, 0); -#endif return; } if (adapter->state != ADAPT_UP) return; - linkup = linkstatus & GIG_LINKUP ? LINK_UP : LINK_DOWN; - if (linkstatus & GIG_SPEED_1000) + linkup = lst & GIG_LINKUP ? LINK_UP : LINK_DOWN; + if (lst & GIG_SPEED_1000) linkspeed = LINK_1000MB; - else if (linkstatus & GIG_SPEED_100) + else if (lst & GIG_SPEED_100) linkspeed = LINK_100MB; else linkspeed = LINK_10MB; - if (linkstatus & GIG_FULLDUPLEX) + if (lst & GIG_FULLDUPLEX) linkduplex = LINK_FULLD; else linkduplex = LINK_HALFD; @@ -1010,81 +1002,77 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr) upr->next = NULL; adapter->upr_busy = 0; switch (upr->upr_request) { - case SLIC_UPR_STATS: - { - struct slic_stats *slicstats = - (struct slic_stats *)&adapter->pshmem->inicstats; - struct slic_stats *newstats = slicstats; - struct slic_stats *old = &adapter->inicstats_prev; - struct slicnet_stats *stst = &adapter->slic_stats; - - if (isr & ISR_UPCERR) { - dev_err(&adapter->netdev->dev, - "SLIC_UPR_STATS command failed isr[%x]\n", -
[PATCH 5/9] staging: slicoss: introduce register accessors that use register offsets
Introduce accessor functions that read and write registers by using a register offset. This is in preparation to replace the register addressing by means of the slic_regs struct with an addressing by means of offsets. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 24 drivers/staging/slicoss/slichw.h | 113 ++ drivers/staging/slicoss/slicoss.c | 1 + 3 files changed, 138 insertions(+) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index cc0afee..08d9f5b 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -418,6 +418,7 @@ struct adapter { dma_addr_t phys_shmem; u32 isrcopy; __iomem struct slic_regs *slic_regs; + void __iomem *regs; unsigned char state; unsigned char linkstate; unsigned char linkspeed; @@ -487,6 +488,29 @@ struct adapter { struct slicnet_stats slic_stats; }; +static inline u32 slic_read32(struct adapter *adapter, unsigned int reg) +{ + return ioread32(adapter->regs + reg); +} + +static inline void slic_write32(struct adapter *adapter, unsigned int reg, + u32 val) +{ + iowrite32(val, adapter->regs + reg); +} + +static inline void slic_write64(struct adapter *adapter, unsigned int reg, + u32 val, u32 hiaddr) +{ + unsigned long flags; + + spin_lock_irqsave(&adapter->bit64reglock, flags); + slic_write32(adapter, SLIC_REG_ADDR_UPPER, hiaddr); + slic_write32(adapter, reg, val); + mmiowb(); + spin_unlock_irqrestore(&adapter->bit64reglock, flags); +} + #define UPDATE_STATS(largestat, newstat, oldstat)\ {\ if ((newstat) < (oldstat)) \ diff --git a/drivers/staging/slicoss/slichw.h b/drivers/staging/slicoss/slichw.h index 9723b4a..f06450e 100644 --- a/drivers/staging/slicoss/slichw.h +++ b/drivers/staging/slicoss/slichw.h @@ -289,6 +289,119 @@ struct slic_rspbuf { u32 pad2[4]; }; +/* Reset Register */ +#define SLIC_REG_RESET 0x +/* Interrupt Control Register */ +#define SLIC_REG_ICR 0x0008 +/* Interrupt status pointer */ +#define SLIC_REG_ISP 0x0010 +/* Interrupt status */ +#define SLIC_REG_ISR 0x0018 +/* + * Header buffer address reg + * 31-8 - phy addr of set of contiguous hdr buffers + * 7-0 - number of buffers passed + * Buffers are 256 bytes long on 256-byte boundaries. + */ +#define SLIC_REG_HBAR 0x0020 +/* + * Data buffer handle & address reg + * 4 sets of registers; Buffers are 2K bytes long 2 per 4K page. + */ +#define SLIC_REG_DBAR 0x0028 +/* + * Xmt Cmd buf addr regs. + * 1 per XMT interface + * 31-5 - phy addr of host command buffer + * 4-0 - length of cmd in multiples of 32 bytes + * Buffers are 32 bytes up to 512 bytes long + */ +#define SLIC_REG_CBAR 0x0030 +/* Write control store */ +#defineSLIC_REG_WCS0x0034 +/* + * Response buffer address reg. + * 31-8 - phy addr of set of contiguous response buffers + * 7-0 - number of buffers passed + * Buffers are 32 bytes long on 32-byte boundaries. + */ +#defineSLIC_REG_RBAR 0x0038 +/* Read statistics (UPR) */ +#defineSLIC_REG_RSTAT 0x0040 +/* Read link status */ +#defineSLIC_REG_LSTAT 0x0048 +/* Write Mac Config */ +#defineSLIC_REG_WMCFG 0x0050 +/* Write phy register */ +#define SLIC_REG_WPHY 0x0058 +/* Rcv Cmd buf addr reg */ +#defineSLIC_REG_RCBAR 0x0060 +/* Read SLIC Config*/ +#define SLIC_REG_RCONFIG 0x0068 +/* Interrupt aggregation time */ +#define SLIC_REG_INTAGG0x0070 +/* Write XMIT config reg */ +#defineSLIC_REG_WXCFG 0x0078 +/* Write RCV config reg */ +#defineSLIC_REG_WRCFG 0x0080 +/* Write rcv addr a low */ +#defineSLIC_REG_WRADDRAL 0x0088 +/* Write rcv addr a high */ +#defineSLIC_REG_WRADDRAH 0x0090 +/* Write rcv addr b low */ +#defineSLIC_REG_WRADDRBL 0x0098 +/* Write rcv addr b high */ +#defineSLIC_REG_WRADDRBH 0x00a0 +/* Low bits of mcast mask */ +#defineSLIC_REG_MCASTLOW 0x00a8 +/* High bits of mcast mask */ +#defineSLIC_REG_MCASTHIGH 0x00b0 +/* Ping the card */ +#define SLIC_REG_PING 0x00b8 +/* Dump command */ +#define SLIC_REG_DUMP_CMD 0x00c0 +/* Dump data pointer */ +#define SLIC_REG_DUMP_DATA 0x00c8 +/* Read card's pci_status register */ +#defineSLIC_REG_PCISTATUS 0x00d0 +/* Write hostid field */ +#define SLIC_REG_WRHOSTID 0x00d8 +/* Put card in a low power state */ +#define SLIC_REG_LOW_POWER 0x00e0 +/*
[PATCH 6/9] staging: slicoss: avoid PCI write posting
Introduce the function slic_flush_write() which reads from the HOSTID register and can be used to avoid PCI write posting. Use the function at several critical places in the code. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 5 + drivers/staging/slicoss/slicoss.c | 19 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 08d9f5b..230d30b 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -511,6 +511,11 @@ static inline void slic_write64(struct adapter *adapter, unsigned int reg, spin_unlock_irqrestore(&adapter->bit64reglock, flags); } +static inline void slic_flush_write(struct adapter *adapter) +{ + ioread32(adapter->regs + SLIC_REG_HOSTID); +} + #define UPDATE_STATS(largestat, newstat, oldstat)\ {\ if ((newstat) < (oldstat)) \ diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index edae0f7..0c2f86a0 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -268,6 +268,7 @@ static void slic_link_config(struct adapter *adapter, */ phy_config = (MIICR_REG_PCR | PCR_POWERDOWN); slic_reg32_write(wphy, phy_config, FLUSH); + slic_flush_write(adapter); /* * wait, Marvell says 1 sec, * try to get away with 10 ms @@ -360,7 +361,7 @@ static void slic_link_config(struct adapter *adapter, /* power down phy to break link (this may not work) */ phy_config = (MIICR_REG_PCR | (PCR_POWERDOWN | speed | duplex)); slic_reg32_write(wphy, phy_config, FLUSH); - + slic_flush_write(adapter); /* wait, Marvell says 1 sec, try to get away with 10 ms */ mdelay(10); @@ -448,6 +449,8 @@ static int slic_card_download_gbrcv(struct adapter *adapter) /* download finished */ release_firmware(fw); slic_reg32_write(&slic_regs->slic_rcv_wcs, SLIC_RCVWCS_FINISH, FLUSH); + slic_flush_write(adapter); + return 0; } @@ -551,6 +554,7 @@ static int slic_card_download(struct adapter *adapter) /* Everything OK, kick off the card */ mdelay(10); slic_reg32_write(&slic_regs->slic_wcs, SLIC_WCS_START, FLUSH); + slic_flush_write(adapter); /* * stall for 20 ms, long enough for ucode to init card @@ -591,11 +595,13 @@ static void slic_soft_reset(struct adapter *adapter) { if (adapter->card->state == CARD_UP) { slic_reg32_write(&adapter->slic_regs->slic_quiesce, 0, FLUSH); + slic_flush_write(adapter); mdelay(1); } slic_reg32_write(&adapter->slic_regs->slic_reset, SLIC_RESET_MAGIC, FLUSH); + slic_flush_write(adapter); mdelay(1); } @@ -934,6 +940,7 @@ static void slic_upr_start(struct adapter *adapter) slic_reg32_write(&slic_regs->slic_ping, 1, FLUSH); break; } + slic_flush_write(adapter); } static int slic_upr_request(struct adapter *adapter, @@ -2153,6 +2160,7 @@ static irqreturn_t slic_interrupt(int irq, void *dev_id) if ((adapter->pshmem) && (adapter->pshmem->isr)) { slic_reg32_write(&adapter->slic_regs->slic_icr, ICR_INT_MASK, FLUSH); + slic_flush_write(adapter); isr = adapter->isrcopy = adapter->pshmem->isr; adapter->pshmem->isr = 0; adapter->num_isrs++; @@ -2337,6 +2345,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags) } slic_reg32_write(&slic_regs->slic_icr, ICR_INT_OFF, FLUSH); + slic_flush_write(adapter); mdelay(1); if (!adapter->isp_initialized) { @@ -2390,11 +2399,13 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags) slic_reg32_write(&slic_regs->slic_icr, ICR_INT_ON, FLUSH); slic_link_config(adapter, LINK_AUTOSPEED, LINK_AUTOD); + slic_flush_write(adapter); rc = slic_link_event_handler(adapter); if (rc) { /* disable interrupts then clear pending events */ slic_reg32_write(&slic_regs->slic_icr, ICR_INT_OFF, FLUSH); slic_reg32_write(&slic_regs->slic_isr, 0, FLUSH); + slic_flush_write(adapter); if (adapter->pingtimerset) {
[PATCH] staging: slicoss: handle allocation failure in slic_init_adapter
The memory allocation in slic_init_adapter() can fail. Return an error in this case and unwind properly. Also make sure that the allocated memory is properly freed in case of an error in the calling probe() function. By doing this also replace the alloc() followed by memset to zero the memory with a zalloc() version. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index ac126d4..dae07410 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2896,10 +2896,10 @@ static void slic_init_driver(void) } } -static void slic_init_adapter(struct net_device *netdev, - struct pci_dev *pcidev, - const struct pci_device_id *pci_tbl_entry, - void __iomem *memaddr, int chip_idx) +static int slic_init_adapter(struct net_device *netdev, +struct pci_dev *pcidev, +const struct pci_device_id *pci_tbl_entry, +void __iomem *memaddr, int chip_idx) { ushort index; struct slic_handle *pslic_handle; @@ -2938,13 +2938,13 @@ static void slic_init_adapter(struct net_device *netdev, pslic_handle->next = adapter->pfree_slic_handles; adapter->pfree_slic_handles = pslic_handle; } - adapter->pshmem = (struct slic_shmem *) - pci_alloc_consistent(adapter->pcidev, - sizeof(struct slic_shmem), - &adapter-> - phys_shmem); - if (adapter->pshmem) - memset(adapter->pshmem, 0, sizeof(struct slic_shmem)); + adapter->pshmem = pci_zalloc_consistent(adapter->pcidev, + sizeof(struct slic_shmem), + &adapter->phys_shmem); + if (!adapter->pshmem) + return -ENOMEM; + + return 0; } static const struct net_device_ops slic_netdev_ops = { @@ -3142,13 +3142,17 @@ static int slic_entry_probe(struct pci_dev *pcidev, slic_init_driver(); - slic_init_adapter(netdev, - pcidev, pci_tbl_entry, memmapped_ioaddr, cards_found); + err = slic_init_adapter(netdev, pcidev, pci_tbl_entry, memmapped_ioaddr, + cards_found); + if (err) { + dev_err(&pcidev->dev, "failed to init adapter: %i\n", err); + goto err_out_unmap; + } err = slic_card_locate(adapter); if (err) { dev_err(&pcidev->dev, "cannot locate card\n"); - goto err_out_unmap; + goto err_clean_init; } card = adapter->card; @@ -3160,7 +3164,7 @@ static int slic_entry_probe(struct pci_dev *pcidev, err = slic_card_init(card, adapter); if (err) - goto err_out_unmap; + goto err_clean_init; slic_adapter_set_hwaddr(adapter); @@ -3172,13 +3176,15 @@ static int slic_entry_probe(struct pci_dev *pcidev, err = register_netdev(netdev); if (err) { dev_err(&pcidev->dev, "Cannot register net device, aborting.\n"); - goto err_out_unmap; + goto err_clean_init; } cards_found++; return 0; +err_clean_init: + slic_init_cleanup(adapter); err_out_unmap: iounmap(memmapped_ioaddr); err_out_free_netdev: -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Aw: Re: [PATCH 0/6] hv_netvsc: avoid races on mtu change/set channels
> It's worse: before the patch series we get 'struct hv_device' (as it is > called from core VMBus code and we simply cannot get to 'struct > net_device' we need without traveling through 'struct > netvsc_device'. This structure is removed and re-created by both > netvsc_set_channels() and netvsc_change_mtu(). Ah ok, I missed that we cant rely on getting a valid netdev from the hv_device in remove. Thanks for the explanation! Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Aw: [PATCH 0/6] hv_netvsc: avoid races on mtu change/set channels
Hi, > > MTU change and set channels operations are implemented as netvsc device > re-creation destroying internal structures (struct net_device stays). This > is really unfortunate but there is no support from Hyper-V host to do it > in a different way. Such re-creation is unsurprisingly racy, Haiyang > reported a crash when netvsc_change_mtu() is racing with > netvsc_link_change() but I was able to identify additional races upon > investigation. Both netvsc_set_channels() and netvsc_change_mtu() race > against: > 1) netvsc_link_change() > 2) netvsc_remove() > 3) netvsc_send() > after having a look into this driver I got the impression that you are working around an unfortunate implementation of the shutdown sequence in the remove function: If you do unregister_netdev() first instead of resource cleanup then neither set_channels() nor change_mtu() can race with remove(). This is since after unregister_netdev() returns the netdev is not longer available from userspace and thus neither set_channels nor change_mtu can be called anymore (note that all of these functions are protected by the rtnl_lock). To avoid the race between netvsc_change_mtu()/netvsc_set_channels() and netvsc_link_change() you have to stop the concerning worker thread (dwork) before you call netvsc_close() and restart it once the device is up again. Regards, Lino ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel