* [PATCH 1/6] arcnet: leds: Removed leds dependecy
From: Andrea Greco @ 2018-06-11 14:25 UTC (permalink / raw)
To: davem; +Cc: tobin, Andrea Greco, Michael Grzeschik, netdev, linux-kernel
From: Andrea Greco <a.greco@4sigma.it>
Only PCI driver depends from leds class.
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
drivers/net/arcnet/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
index 39bd16f3f86d..afc5898e7a16 100644
--- a/drivers/net/arcnet/Kconfig
+++ b/drivers/net/arcnet/Kconfig
@@ -103,7 +103,6 @@ config ARCNET_RIM_I
config ARCNET_COM20020
tristate "ARCnet COM20020 chipset driver"
- depends on LEDS_CLASS
help
This is the driver for the new COM20020 chipset. It supports such
things as promiscuous mode, so packet sniffing is possible, and
@@ -118,6 +117,7 @@ config ARCNET_COM20020_ISA
config ARCNET_COM20020_PCI
tristate "Support for COM20020 on PCI"
+ depends on LEDS_CLASS
depends on ARCNET_COM20020 && PCI
config ARCNET_COM20020_CS
--
2.14.4
^ permalink raw reply related
* [PATCH 2/6] arcnet: com20020: Add IO cb for configure rw
From: Andrea Greco @ 2018-06-11 14:26 UTC (permalink / raw)
To: davem; +Cc: tobin, Andrea Greco, Michael Grzeschik, netdev, linux-kernel
From: Andrea Greco <a.greco@4sigma.it>
Add IO callback. No logic change are intended.
Now every driver implementation could specify IO callback.
Default IO callback is provided.
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
drivers/net/arcnet/arcdevice.h | 4 ++
drivers/net/arcnet/com20020-isa.c | 21 ++++--
drivers/net/arcnet/com20020-pci.c | 11 +++-
drivers/net/arcnet/com20020.c | 134 ++++++++++++++++++++++++--------------
drivers/net/arcnet/com20020.h | 9 ++-
drivers/net/arcnet/com20020_cs.c | 23 +++++--
6 files changed, 134 insertions(+), 68 deletions(-)
diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index d09b2b46ab63..cb7afadac5f6 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -324,6 +324,10 @@ struct arcnet_local {
void (*close)(struct net_device *dev);
void (*datatrigger) (struct net_device * dev, int enable);
void (*recontrigger) (struct net_device * dev, int enable);
+ unsigned int (*arc_inb)(int addr, int offset);
+ void (*arc_outb)(int value, int addr, int offset);
+ void (*arc_insb)(int addr, int offset, void *buff, int cnt);
+ void (*arc_outsb)(int addr, int offset, void *buff, int cnt);
void (*copy_to_card)(struct net_device *dev, int bufnum,
int offset, void *buf, int count);
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index 38fa60ddaf2e..757586de5d08 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -67,7 +67,7 @@ static int __init com20020isa_probe(struct net_device *dev)
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
- if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
+ if (lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
arc_printk(D_NORMAL, dev, "IO address %x empty\n", ioaddr);
err = -ENODEV;
goto out;
@@ -83,20 +83,21 @@ static int __init com20020isa_probe(struct net_device *dev)
* we tell it to start receiving.
*/
arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
- arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
- arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
+ lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS));
+ lp->hw.arc_outb(0, ioaddr, COM20020_REG_W_INTMASK);
airqmask = probe_irq_on();
- arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
+ lp->hw.arc_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
udelay(1);
- arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
+ lp->hw.arc_outb(0, ioaddr, COM20020_REG_W_INTMASK);
dev->irq = probe_irq_off(airqmask);
if ((int)dev->irq <= 0) {
arc_printk(D_INIT_REASONS, dev, "Autoprobe IRQ failed first time\n");
airqmask = probe_irq_on();
- arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
+ lp->hw.arc_outb(NORXflag, ioaddr,
+ COM20020_REG_W_INTMASK);
udelay(5);
- arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
+ lp->hw.arc_outb(0, ioaddr, COM20020_REG_W_INTMASK);
dev->irq = probe_irq_off(airqmask);
if ((int)dev->irq <= 0) {
arc_printk(D_NORMAL, dev, "Autoprobe IRQ failed.\n");
@@ -156,6 +157,12 @@ static int __init com20020_init(void)
dev->netdev_ops = &com20020_netdev_ops;
lp = netdev_priv(dev);
+
+ lp->hw.arc_inb = com20020_def_arc_inb;
+ lp->hw.arc_outb = com20020_def_arc_outb;
+ lp->hw.arc_insb = com20020_def_arc_insb;
+ lp->hw.arc_outsb = com20020_def_arc_outsb;
+
lp->backplane = backplane;
lp->clockp = clockp & 7;
lp->clockm = clockm & 3;
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index eb7f76753c9c..dcf12e5cf889 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -181,12 +181,17 @@ static int com20020pci_probe(struct pci_dev *pdev,
goto out_port;
}
+ lp->hw.arc_inb = com20020_def_arc_inb;
+ lp->hw.arc_outb = com20020_def_arc_outb;
+ lp->hw.arc_insb = com20020_def_arc_insb;
+ lp->hw.arc_outsb = com20020_def_arc_outsb;
+
/* Dummy access after Reset
* ARCNET controller needs
* this access to detect bustype
*/
- arcnet_outb(0x00, ioaddr, COM20020_REG_W_COMMAND);
- arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT);
+ lp->hw.arc_outb(0x00, ioaddr, COM20020_REG_W_COMMAND);
+ lp->hw.arc_inb(ioaddr, COM20020_REG_R_DIAGSTAT);
SET_NETDEV_DEV(dev, &pdev->dev);
dev->base_addr = ioaddr;
@@ -213,7 +218,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, i);
- if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
+ if (lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
pr_err("IO address %Xh is empty!\n", ioaddr);
ret = -EIO;
goto out_port;
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 78043a9c5981..cbcea7834378 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -59,44 +59,75 @@ static void com20020_copy_from_card(struct net_device *dev, int bufnum,
static void com20020_set_mc_list(struct net_device *dev);
static void com20020_close(struct net_device *);
+unsigned int com20020_def_arc_inb(int addr, int offset)
+{
+ return inb(addr + offset);
+}
+EXPORT_SYMBOL(com20020_def_arc_inb);
+
+void com20020_def_arc_outb(int value, int addr, int offset)
+{
+ outb(value, addr + offset);
+}
+EXPORT_SYMBOL(com20020_def_arc_outb);
+
+void com20020_def_arc_insb(int addr, int offset, void *buffer, int count)
+{
+ insb(addr + offset, buffer, count);
+}
+EXPORT_SYMBOL(com20020_def_arc_insb);
+
+void com20020_def_arc_outsb(int addr, int offset, void *buffer, int count)
+{
+ outsb(addr + offset, buffer, count);
+}
+EXPORT_SYMBOL(com20020_def_arc_outsb);
+
static void com20020_copy_from_card(struct net_device *dev, int bufnum,
int offset, void *buf, int count)
{
- int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;
+ int ioaddr = dev->base_addr;
+ int ofs = 512 * bufnum + offset;
+ struct arcnet_local *lp = netdev_priv(dev);
/* set up the address register */
- arcnet_outb((ofs >> 8) | RDDATAflag | AUTOINCflag,
+ lp->hw.arc_outb((ofs >> 8) | RDDATAflag | AUTOINCflag,
ioaddr, COM20020_REG_W_ADDR_HI);
- arcnet_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
+ lp->hw.arc_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
/* copy the data */
TIME(dev, "insb", count,
- arcnet_insb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count));
+ lp->hw.arc_insb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count));
}
static void com20020_copy_to_card(struct net_device *dev, int bufnum,
int offset, void *buf, int count)
{
- int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;
+ int ioaddr = dev->base_addr;
+ int ofs = 512 * bufnum + offset;
+ struct arcnet_local *lp = netdev_priv(dev);
/* set up the address register */
- arcnet_outb((ofs >> 8) | AUTOINCflag, ioaddr, COM20020_REG_W_ADDR_HI);
- arcnet_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
+ lp->hw.arc_outb((ofs >> 8) | AUTOINCflag,
+ ioaddr, COM20020_REG_W_ADDR_HI);
+ lp->hw.arc_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
/* copy the data */
TIME(dev, "outsb", count,
- arcnet_outsb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count));
+ lp->hw.arc_outsb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count));
}
/* Reset the card and check some basic stuff during the detection stage. */
int com20020_check(struct net_device *dev)
{
- int ioaddr = dev->base_addr, status;
+ int ioaddr = dev->base_addr;
struct arcnet_local *lp = netdev_priv(dev);
+ int status;
- arcnet_outb(XTOcfg(3) | RESETcfg, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(XTOcfg(3) | RESETcfg, ioaddr,
+ COM20020_REG_W_CONFIG);
udelay(5);
- arcnet_outb(XTOcfg(3), ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(XTOcfg(3), ioaddr, COM20020_REG_W_CONFIG);
mdelay(RESETtime);
lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
@@ -107,23 +138,23 @@ int com20020_check(struct net_device *dev)
lp->setup = lp->setup | P1MODE;
com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
- arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
if (lp->clockm != 0) {
com20020_set_subaddress(lp, ioaddr, SUB_SETUP2);
- arcnet_outb(lp->setup2, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->setup2, ioaddr, COM20020_REG_W_XREG);
/* must now write the magic "restart operation" command */
mdelay(1);
- arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
+ lp->hw.arc_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
- arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(0x42, ioaddr, COM20020_REG_W_XREG);
- status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
+ status = lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS);
if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
arc_printk(D_NORMAL, dev, "status invalid (%Xh).\n", status);
@@ -131,18 +162,18 @@ int com20020_check(struct net_device *dev)
}
arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
- arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
+ lp->hw.arc_outb(CFLAGScmd | RESETclear | CONFIGclear,
ioaddr, COM20020_REG_W_COMMAND);
- status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
+ status = lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS);
arc_printk(D_INIT_REASONS, dev, "status after reset acknowledged: %X\n",
status);
/* Read first location of memory */
- arcnet_outb(0 | RDDATAflag | AUTOINCflag,
+ lp->hw.arc_outb(0 | RDDATAflag | AUTOINCflag,
ioaddr, COM20020_REG_W_ADDR_HI);
- arcnet_outb(0, ioaddr, COM20020_REG_W_ADDR_LO);
+ lp->hw.arc_outb(0, ioaddr, COM20020_REG_W_ADDR_LO);
- status = arcnet_inb(ioaddr, COM20020_REG_RW_MEMDATA);
+ status = lp->hw.arc_inb(ioaddr, COM20020_REG_RW_MEMDATA);
if (status != TESTvalue) {
arc_printk(D_NORMAL, dev, "Signature byte not found (%02Xh != D1h).\n",
status);
@@ -159,7 +190,7 @@ static int com20020_set_hwaddr(struct net_device *dev, void *addr)
memcpy(dev->dev_addr, hwaddr->sa_data, 1);
com20020_set_subaddress(lp, ioaddr, SUB_NODE);
- arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
return 0;
}
@@ -170,7 +201,7 @@ static int com20020_netdev_open(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);
lp->config |= TXENcfg;
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
return arcnet_open(dev);
}
@@ -184,7 +215,7 @@ static int com20020_netdev_close(struct net_device *dev)
/* disable transmitter */
lp->config &= ~TXENcfg;
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
return 0;
}
@@ -203,6 +234,7 @@ const struct net_device_ops com20020_netdev_ops = {
int com20020_found(struct net_device *dev, int shared)
{
struct arcnet_local *lp;
+
int ioaddr = dev->base_addr;
/* Initialize the rest of the device structure. */
@@ -220,24 +252,24 @@ int com20020_found(struct net_device *dev, int shared)
/* FIXME: do this some other way! */
if (!dev->dev_addr[0])
- dev->dev_addr[0] = arcnet_inb(ioaddr, 8);
+ dev->dev_addr[0] = lp->hw.arc_inb(ioaddr, 8);
com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
- arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
if (lp->card_flags & ARC_CAN_10MBIT) {
com20020_set_subaddress(lp, ioaddr, SUB_SETUP2);
- arcnet_outb(lp->setup2, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->setup2, ioaddr, COM20020_REG_W_XREG);
/* must now write the magic "restart operation" command */
mdelay(1);
- arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
+ lp->hw.arc_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* Default 0x38 + register: Node ID */
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
- arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
/* reserve the irq */
if (request_irq(dev->irq, arcnet_interrupt, shared,
@@ -282,31 +314,32 @@ int com20020_found(struct net_device *dev, int shared)
static int com20020_reset(struct net_device *dev, int really_reset)
{
struct arcnet_local *lp = netdev_priv(dev);
- u_int ioaddr = dev->base_addr;
+ int ioaddr = dev->base_addr;
u_char inbyte;
arc_printk(D_DEBUG, dev, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
__FILE__, __LINE__, __func__, dev, lp, dev->name);
arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
- dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
+ dev->name, lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS));
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
lp->config |= (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
if (really_reset) {
/* reset the card */
- arcnet_outb(lp->config | RESETcfg, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config | RESETcfg, ioaddr,
+ COM20020_REG_W_CONFIG);
udelay(5);
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
mdelay(RESETtime * 2);
/* COM20020 seems to be slower sometimes */
}
/* clear flags & end reset */
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
- arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
+ lp->hw.arc_outb(CFLAGScmd | RESETclear | CONFIGclear,
ioaddr, COM20020_REG_W_COMMAND);
/* verify that the ARCnet signature byte is present */
@@ -321,7 +354,7 @@ static int com20020_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM20020_REG_W_COMMAND);
+ lp->hw.arc_outb(CONFIGcmd | EXTconf, ioaddr, COM20020_REG_W_COMMAND);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
@@ -331,35 +364,38 @@ static int com20020_reset(struct net_device *dev, int really_reset)
static void com20020_setmask(struct net_device *dev, int mask)
{
- u_int ioaddr = dev->base_addr;
+ int ioaddr = dev->base_addr;
+ struct arcnet_local *lp = netdev_priv(dev);
arc_printk(D_DURING, dev, "Setting mask to %x at %x\n", mask, ioaddr);
- arcnet_outb(mask, ioaddr, COM20020_REG_W_INTMASK);
+ lp->hw.arc_outb(mask, ioaddr, COM20020_REG_W_INTMASK);
}
static void com20020_command(struct net_device *dev, int cmd)
{
- u_int ioaddr = dev->base_addr;
+ int ioaddr = dev->base_addr;
+ struct arcnet_local *lp = netdev_priv(dev);
- arcnet_outb(cmd, ioaddr, COM20020_REG_W_COMMAND);
+ lp->hw.arc_outb(cmd, ioaddr, COM20020_REG_W_COMMAND);
}
static int com20020_status(struct net_device *dev)
{
- u_int ioaddr = dev->base_addr;
+ int ioaddr = dev->base_addr;
+ struct arcnet_local *lp = netdev_priv(dev);
- return arcnet_inb(ioaddr, COM20020_REG_R_STATUS) +
- (arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT) << 8);
+ return lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS) +
+ (lp->hw.arc_inb(ioaddr, COM20020_REG_R_DIAGSTAT) << 8);
}
static void com20020_close(struct net_device *dev)
{
- struct arcnet_local *lp = netdev_priv(dev);
int ioaddr = dev->base_addr;
+ struct arcnet_local *lp = netdev_priv(dev);
/* disable transmitter */
lp->config &= ~TXENcfg;
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
}
/* Set or clear the multicast filter for this adaptor.
@@ -380,14 +416,14 @@ static void com20020_set_mc_list(struct net_device *dev)
arc_printk(D_NORMAL, dev, "Setting promiscuous flag...\n");
com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
lp->setup |= PROMISCset;
- arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
} else {
/* Disable promiscuous mode, use normal mode */
if ((lp->setup & PROMISCset))
arc_printk(D_NORMAL, dev, "Resetting promiscuous flag...\n");
com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
lp->setup &= ~PROMISCset;
- arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
+ lp->hw.arc_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
}
}
diff --git a/drivers/net/arcnet/com20020.h b/drivers/net/arcnet/com20020.h
index 0bcc5d0a6903..af18c7edc4fa 100644
--- a/drivers/net/arcnet/com20020.h
+++ b/drivers/net/arcnet/com20020.h
@@ -118,14 +118,19 @@ struct com20020_dev {
#define SUB_BUSCTL 5 /* bus control options */
#define SUB_DMACOUNT 6 /* DMA count options */
+unsigned int com20020_def_arc_inb(int addr, int offset);
+void com20020_def_arc_outb(int value, int addr, int offset);
+void com20020_def_arc_insb(int addr, int offset, void *buffer, int count);
+void com20020_def_arc_outsb(int addr, int offset, void *buffer, int count);
+
static inline void com20020_set_subaddress(struct arcnet_local *lp,
int ioaddr, int val)
{
if (val < 4) {
lp->config = (lp->config & ~0x03) | val;
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
} else {
- arcnet_outb(val, ioaddr, COM20020_REG_W_SUBADR);
+ lp->hw.arc_outb(val, ioaddr, COM20020_REG_W_SUBADR);
}
}
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index cf607ffcf358..bca4e6c15e4f 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -53,29 +53,31 @@ static void regdump(struct net_device *dev)
{
#ifdef DEBUG
int ioaddr = dev->base_addr;
+ struct arcnet_local *lp = netdev_priv(dev);
int count;
netdev_dbg(dev, "register dump:\n");
for (count = 0; count < 16; count++) {
if (!(count % 16))
pr_cont("%04X:", ioaddr + count);
- pr_cont(" %02X", arcnet_inb(ioaddr, count));
+ pr_cont(" %02X", lp->hw.arc_inb(ioaddr, count));
}
pr_cont("\n");
netdev_dbg(dev, "buffer0 dump:\n");
/* set up the address register */
count = 0;
- arcnet_outb((count >> 8) | RDDATAflag | AUTOINCflag,
- ioaddr, com20020_REG_W_ADDR_HI);
- arcnet_outb(count & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
+ lp->hw.arc_outb((count >> 8) | RDDATAflag | AUTOINCflag,
+ ioaddr, com20020_REG_W_ADDR_HI);
+ lp->hw.arc_outb(count & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
for (count = 0; count < 256 + 32; count++) {
if (!(count % 16))
pr_cont("%04X:", count);
/* copy the data */
- pr_cont(" %02X", arcnet_inb(ioaddr, COM20020_REG_RW_MEMDATA));
+ pr_cont(" %02X", lp->hw.arc_inb(ioaddr,
+ COM20020_REG_RW_MEMDATA));
}
pr_cont("\n");
#endif
@@ -126,6 +128,12 @@ static int com20020_probe(struct pcmcia_device *p_dev)
goto fail_alloc_dev;
lp = netdev_priv(dev);
+
+ lp->hw.arc_inb = com20020_def_arc_inb;
+ lp->hw.arc_outb = com20020_def_arc_outb;
+ lp->hw.arc_insb = com20020_def_arc_insb;
+ lp->hw.arc_outsb = com20020_def_arc_outsb;
+
lp->timeout = timeout;
lp->backplane = backplane;
lp->clockp = clockp;
@@ -293,9 +301,10 @@ static int com20020_resume(struct pcmcia_device *link)
int ioaddr = dev->base_addr;
struct arcnet_local *lp = netdev_priv(dev);
- arcnet_outb(lp->config | 0x80, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config | 0x80, ioaddr,
+ COM20020_REG_W_CONFIG);
udelay(5);
- arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+ lp->hw.arc_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
}
return 0;
--
2.14.4
^ permalink raw reply related
* [PATCH 3/6] arcnet: com20020: Add com20020 io mapped version
From: Andrea Greco @ 2018-06-11 14:26 UTC (permalink / raw)
To: davem; +Cc: tobin, Andrea Greco, Michael Grzeschik, linux-kernel, netdev
From: Andrea Greco <a.greco@4sigma.it>
Add support for com20022I/com20020, io mapped.
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
drivers/net/arcnet/Kconfig | 9 +-
drivers/net/arcnet/Makefile | 1 +
drivers/net/arcnet/com20020-io.c | 315 +++++++++++++++++++++++++++++++++++++++
drivers/net/arcnet/com20020.c | 5 +-
4 files changed, 327 insertions(+), 3 deletions(-)
create mode 100644 drivers/net/arcnet/com20020-io.c
diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
index afc5898e7a16..f72620dc63ec 100644
--- a/drivers/net/arcnet/Kconfig
+++ b/drivers/net/arcnet/Kconfig
@@ -3,7 +3,7 @@
#
menuconfig ARCNET
- depends on NETDEVICES && (ISA || PCI || PCMCIA)
+ depends on NETDEVICES
tristate "ARCnet support"
---help---
If you have a network card of this type, say Y and check out the
@@ -129,5 +129,12 @@ config ARCNET_COM20020_CS
To compile this driver as a module, choose M here: the module will be
called com20020_cs. If unsure, say N.
+config ARCNET_COM20020_IO
+ tristate "Support for COM20020 (IO mapped)"
+ depends on ARCNET_COM20020
+ help
+ Say Y here if your custom board mount com20020 chipset or friends.
+ Supported Chipset: com20020, com20022, com20022I-3v3
+ If unsure, say N.
endif # ARCNET
diff --git a/drivers/net/arcnet/Makefile b/drivers/net/arcnet/Makefile
index 53525e8ea130..18da4341f404 100644
--- a/drivers/net/arcnet/Makefile
+++ b/drivers/net/arcnet/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_ARCNET_COM20020) += com20020.o
obj-$(CONFIG_ARCNET_COM20020_ISA) += com20020-isa.o
obj-$(CONFIG_ARCNET_COM20020_PCI) += com20020-pci.o
obj-$(CONFIG_ARCNET_COM20020_CS) += com20020_cs.o
+obj-$(CONFIG_ARCNET_COM20020_IO) += com20020-io.o
diff --git a/drivers/net/arcnet/com20020-io.c b/drivers/net/arcnet/com20020-io.c
new file mode 100644
index 000000000000..23c24d4de5a9
--- /dev/null
+++ b/drivers/net/arcnet/com20020-io.c
@@ -0,0 +1,315 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/* Linux ARCnet driver for com 20020.
+ *
+ * datasheet:
+ * http://ww1.microchip.com/downloads/en/DeviceDoc/200223vrevc.pdf
+ * http://ww1.microchip.com/downloads/en/DeviceDoc/20020.pdf
+ *
+ * Supported chip version:
+ * - com20020
+ * - com20022
+ * - com20022I-3v3
+ */
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/platform_device.h>
+#include <linux/netdevice.h>
+#include <linux/of_address.h>
+#include <linux/of_gpio.h>
+#include <linux/sizes.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include "arcdevice.h"
+#include "com20020.h"
+
+/* Reset (5 * xTalFreq), minimal com20020 xTal is 10Mhz */
+#define RESET_DELAY 500
+
+static unsigned int io_arc_inb(int addr, int offset)
+{
+ return ioread8((void *__iomem) addr + offset);
+}
+
+static void io_arc_outb(int value, int addr, int offset)
+{
+ iowrite8(value, (void *__iomem)addr + offset);
+}
+
+static void io_arc_insb(int addr, int offset, void *buffer, int count)
+{
+ ioread8_rep((void *__iomem) (addr + offset), buffer, count);
+}
+
+static void io_arc_outsb(int addr, int offset, void *buffer, int count)
+{
+ iowrite8_rep((void *__iomem) (addr + offset), buffer, count);
+}
+
+enum com20020_xtal_freq {
+ freq_10Mhz = 10,
+ freq_20Mhz = 20,
+};
+
+enum com20020_arcnet_speed {
+ arc_speed_10M_bps = 10000000,
+ arc_speed_5M_bps = 5000000,
+ arc_speed_2M50_bps = 2500000,
+ arc_speed_1M25_bps = 1250000,
+ arc_speed_625K_bps = 625000,
+ arc_speed_312K5_bps = 312500,
+ arc_speed_156K25_bps = 156250,
+};
+
+enum com20020_timeout {
+ arc_timeout_328us = 328000,
+ arc_timeout_164us = 164000,
+ arc_timeout_82us = 82000,
+ arc_timeout_20u5s = 20500,
+};
+
+static int setup_clock(int *clockp, int *clockm, int xtal, int arcnet_speed)
+{
+ int pll_factor, req_clock_frq = 20;
+
+ switch (arcnet_speed) {
+ case arc_speed_10M_bps:
+ req_clock_frq = 80;
+ *clockp = 0;
+ break;
+ case arc_speed_5M_bps:
+ req_clock_frq = 40;
+ *clockp = 0;
+ break;
+ case arc_speed_2M50_bps:
+ *clockp = 0;
+ break;
+ case arc_speed_1M25_bps:
+ *clockp = 1;
+ break;
+ case arc_speed_625K_bps:
+ *clockp = 2;
+ break;
+ case arc_speed_312K5_bps:
+ *clockp = 3;
+ break;
+ case arc_speed_156K25_bps:
+ *clockp = 4;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (xtal != freq_10Mhz && xtal != freq_20Mhz)
+ return -EINVAL;
+
+ pll_factor = (unsigned int)req_clock_frq / xtal;
+
+ switch (pll_factor) {
+ case 1:
+ *clockm = 0;
+ break;
+ case 2:
+ *clockm = 1;
+ break;
+ case 4:
+ *clockm = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int setup_timeout(int *timeout)
+{
+ switch (*timeout) {
+ case arc_timeout_328us:
+ *timeout = 0;
+ break;
+ case arc_timeout_164us:
+ *timeout = 1;
+ break;
+ case arc_timeout_82us:
+ *timeout = 2;
+ break;
+ case arc_timeout_20u5s:
+ *timeout = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int com20020_probe(struct platform_device *pdev)
+{
+ struct device_node *np;
+ struct net_device *dev;
+ struct arcnet_local *lp;
+ struct resource res, *iores;
+ int ret, phy_reset;
+ u32 timeout, xtal, arc_speed;
+ int clockp, clockm;
+ bool backplane = false;
+ int ioaddr;
+
+ np = pdev->dev.of_node;
+
+ iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+ ret = of_address_to_resource(np, 0, &res);
+ if (ret)
+ return ret;
+
+ ret = of_property_read_u32(np, "timeout-ns", &timeout);
+ if (ret) {
+ dev_err(&pdev->dev, "timeout is required param");
+ return ret;
+ }
+
+ ret = of_property_read_u32(np, "smsc,xtal-mhz", &xtal);
+ if (ret) {
+ dev_err(&pdev->dev, "xtal-mhz is required param");
+ return ret;
+ }
+
+ ret = of_property_read_u32(np, "bus-speed-bps", &arc_speed);
+ if (ret) {
+ dev_err(&pdev->dev, "Bus speed is required param");
+ return ret;
+ }
+
+ if (of_property_read_bool(np, "smsc,backplane-enabled"))
+ backplane = true;
+
+ phy_reset = of_get_named_gpio(np, "reset-gpios", 0);
+ if (!gpio_is_valid(phy_reset)) {
+ dev_err(&pdev->dev, "reset gpio not valid");
+ return phy_reset;
+ }
+
+ ret = devm_gpio_request_one(&pdev->dev, phy_reset, GPIOF_OUT_INIT_LOW,
+ "arcnet-reset");
+ if (ret) {
+ dev_err(&pdev->dev, "failed to get phy reset gpio: %d\n", ret);
+ return ret;
+ }
+
+ dev = alloc_arcdev(NULL);
+ dev->netdev_ops = &com20020_netdev_ops;
+ lp = netdev_priv(dev);
+
+ lp->card_flags = ARC_CAN_10MBIT;
+
+ /* Peak random address,
+ * if required user could set a new-one in userspace
+ */
+ get_random_bytes(dev->dev_addr, dev->addr_len);
+
+ if (!devm_request_mem_region(&pdev->dev, res.start, resource_size(&res),
+ lp->card_name))
+ return -EBUSY;
+
+ ioaddr = (int)devm_ioremap(&pdev->dev, iores->start,
+ resource_size(iores));
+ if (!ioaddr) {
+ dev_err(&pdev->dev, "ioremap fallied\n");
+ return -ENOMEM;
+ }
+
+ gpio_set_value_cansleep(phy_reset, 0);
+ ndelay(RESET_DELAY);
+ gpio_set_value_cansleep(phy_reset, 1);
+
+ lp->hw.arc_inb = io_arc_inb;
+ lp->hw.arc_outb = io_arc_outb;
+ lp->hw.arc_insb = io_arc_insb;
+ lp->hw.arc_outsb = io_arc_outsb;
+
+ /* ARCNET controller needs this access to detect bustype */
+ lp->hw.arc_outb(0x00, ioaddr, COM20020_REG_W_COMMAND);
+ lp->hw.arc_inb(ioaddr, COM20020_REG_R_DIAGSTAT);
+
+ dev->base_addr = (unsigned long)ioaddr;
+
+ dev->irq = of_get_named_gpio(np, "interrupts", 0);
+ if (dev->irq == -EPROBE_DEFER) {
+ return dev->irq;
+ } else if (!gpio_is_valid(dev->irq)) {
+ dev_err(&pdev->dev, "irq-gpios not valid !");
+ return -EIO;
+ }
+ dev->irq = gpio_to_irq(dev->irq);
+
+ ret = setup_clock(&clockp, &clockm, xtal, arc_speed);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "Impossible use oscillator:%dMhz and arcnet bus speed:%dKbps",
+ xtal, arc_speed / 1000);
+ return ret;
+ }
+
+ ret = setup_timeout(&timeout);
+ if (ret) {
+ dev_err(&pdev->dev, "Timeout:%d is not valid value", timeout);
+ return ret;
+ }
+
+ lp->backplane = (int)backplane;
+ lp->timeout = timeout;
+ lp->clockm = clockm;
+ lp->clockp = clockp;
+ lp->hw.owner = THIS_MODULE;
+
+ if (lp->hw.arc_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
+ ret = -EIO;
+ goto err_release_mem;
+ }
+
+ if (com20020_check(dev)) {
+ ret = -EIO;
+ goto err_release_mem;
+ }
+
+ ret = com20020_found(dev, IRQF_TRIGGER_FALLING);
+ if (ret)
+ goto err_release_mem;
+
+ dev_dbg(&pdev->dev, "probe Done\n");
+ return 0;
+
+err_release_mem:
+ devm_iounmap(&pdev->dev, (void __iomem *)ioaddr);
+ devm_release_mem_region(&pdev->dev, res.start, resource_size(&res));
+ dev_err(&pdev->dev, "probe failed!\n");
+ return ret;
+}
+
+static const struct of_device_id of_com20020_match[] = {
+ { .compatible = "smsc,com20020", },
+ { },
+};
+
+MODULE_DEVICE_TABLE(of, of_com20020_match);
+
+static struct platform_driver of_com20020_driver = {
+ .driver = {
+ .name = "com20020-memory-bus",
+ .of_match_table = of_com20020_match,
+ },
+ .probe = com20020_probe,
+};
+
+static int com20020_init(void)
+{
+ return platform_driver_register(&of_com20020_driver);
+}
+late_initcall(com20020_init);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index cbcea7834378..8d979a66d8e9 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -43,7 +43,7 @@
#include "com20020.h"
static const char * const clockrates[] = {
- "XXXXXXX", "XXXXXXXX", "XXXXXX", "2.5 Mb/s",
+ "10 Mb/s", "XXXXXXXX", "XXXXXX", "2.5 Mb/s",
"1.25Mb/s", "625 Kb/s", "312.5 Kb/s", "156.25 Kb/s",
"Reserved", "Reserved", "Reserved"
};
@@ -429,7 +429,8 @@ static void com20020_set_mc_list(struct net_device *dev)
#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \
- defined(CONFIG_ARCNET_COM20020_CS_MODULE)
+ defined(CONFIG_ARCNET_COM20020_CS_MODULE) || \
+ defined(CONFIG_ARCNET_COM20020_IO)
EXPORT_SYMBOL(com20020_check);
EXPORT_SYMBOL(com20020_found);
EXPORT_SYMBOL(com20020_netdev_ops);
--
2.14.4
^ permalink raw reply related
* [PATCH 4/6] arcnet: com20020: bindings for smsc com20020
From: Andrea Greco @ 2018-06-11 14:27 UTC (permalink / raw)
To: davem
Cc: tobin, Andrea Greco, Rob Herring, Mark Rutland, netdev,
devicetree, linux-kernel
From: Andrea Greco <a.greco@4sigma.it>
Add devicetree bindings for smsc com20020
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
.../devicetree/bindings/net/smsc-com20020.txt | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/smsc-com20020.txt
diff --git a/Documentation/devicetree/bindings/net/smsc-com20020.txt b/Documentation/devicetree/bindings/net/smsc-com20020.txt
new file mode 100644
index 000000000000..660a4a751f29
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/smsc-com20020.txt
@@ -0,0 +1,21 @@
+SMSC com20020 Arcnet network controller
+
+Required property:
+- timeout-ns: Arcnet bus timeout, Idle Time (328000 - 20500)
+- bus-speed-bps: Arcnet bus speed (10000000 - 156250)
+- smsc,xtal-mhz: External oscillator frequency
+- smsc,backplane-enabled: Controller use backplane mode
+- reset-gpios: Chip reset pin
+- interrupts: Should contain controller interrupt
+
+arcnet@28000000 {
+ compatible = "smsc,com20020";
+
+ timeout-ns = <20500>;
+ bus-speed-hz = <10000000>;
+ smsc,xtal-mhz = <20>;
+ smsc,backplane-enabled;
+
+ reset-gpios = <&gpio3 21 GPIO_ACTIVE_LOW>;
+ interrupts = <&gpio2 10 GPIO_ACTIVE_LOW>;
+};
--
2.14.4
^ permalink raw reply related
* [PATCH 5/6] arcnet: com20020: Fixup missing SLOWARB bit
From: Andrea Greco @ 2018-06-11 14:27 UTC (permalink / raw)
To: davem; +Cc: tobin, Andrea Greco, Michael Grzeschik, netdev, linux-kernel
From: Andrea Greco <a.greco@4sigma.it>
If com20020 clock is major of 40Mhz SLOWARB bit is requested.
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
drivers/net/arcnet/com20020.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 8d979a66d8e9..1a0fd30fe8ae 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -133,6 +133,10 @@ int com20020_check(struct net_device *dev)
lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
lp->setup2 = (lp->clockm << 4) | 8;
+ /* If clock is major of 40Mhz, SLOWARB bit must be set */
+ if (lp->clockm > 1)
+ lp->setup2 |= SLOWARB;
+
/* CHECK: should we do this for SOHARD cards ? */
/* Enable P1Mode for backplane mode */
lp->setup = lp->setup | P1MODE;
--
2.14.4
^ permalink raw reply related
* [PATCH 6/6] arcnet: com20020: Add ethtool support
From: Andrea Greco @ 2018-06-11 14:27 UTC (permalink / raw)
To: davem; +Cc: tobin, Andrea Greco, Michael Grzeschik, netdev, linux-kernel
From: Andrea Greco <a.greco@4sigma.it>
Setup ethtols for export com20020 diag register
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
drivers/net/arcnet/com20020-io.c | 1 +
drivers/net/arcnet/com20020-isa.c | 1 +
drivers/net/arcnet/com20020.c | 24 ++++++++++++++++++++++++
drivers/net/arcnet/com20020.h | 1 +
drivers/net/arcnet/com20020_cs.c | 1 +
include/uapi/linux/if_arcnet.h | 6 ++++++
6 files changed, 34 insertions(+)
diff --git a/drivers/net/arcnet/com20020-io.c b/drivers/net/arcnet/com20020-io.c
index 23c24d4de5a9..9954d3a30ff6 100644
--- a/drivers/net/arcnet/com20020-io.c
+++ b/drivers/net/arcnet/com20020-io.c
@@ -203,6 +203,7 @@ static int com20020_probe(struct platform_device *pdev)
dev = alloc_arcdev(NULL);
dev->netdev_ops = &com20020_netdev_ops;
+ dev->ethtool_ops = &com20020_ethtool_ops;
lp = netdev_priv(dev);
lp->card_flags = ARC_CAN_10MBIT;
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index 757586de5d08..eba1bd82226c 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -155,6 +155,7 @@ static int __init com20020_init(void)
dev->dev_addr[0] = node;
dev->netdev_ops = &com20020_netdev_ops;
+ dev->ethtool_ops = &com20020_ethtool_ops;
lp = netdev_priv(dev);
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 1a0fd30fe8ae..60e5ae401b1b 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -232,6 +232,29 @@ const struct net_device_ops com20020_netdev_ops = {
.ndo_set_rx_mode = com20020_set_mc_list,
};
+static int com20020_ethtool_regs_len(struct net_device *netdev)
+{
+ return sizeof(struct com20020_ethtool_regs);
+}
+
+static void com20020_ethtool_regs_read(struct net_device *dev,
+ struct ethtool_regs *regs, void *p)
+{
+ struct arcnet_local *lp = netdev_priv(dev);
+ struct com20020_ethtool_regs *com_reg = p;
+
+ memset(p, 0, sizeof(struct com20020_ethtool_regs));
+
+ com_reg->status = lp->hw.status(dev) & 0xFF;
+ com_reg->diag_register = (lp->hw.status(dev) >> 8) & 0xFF;
+ com_reg->reconf_count = lp->num_recons;
+}
+
+const struct ethtool_ops com20020_ethtool_ops = {
+ .get_regs = com20020_ethtool_regs_read,
+ .get_regs_len = com20020_ethtool_regs_len,
+};
+
/* Set up the struct net_device associated with this card. Called after
* probing succeeds.
*/
@@ -438,6 +461,7 @@ static void com20020_set_mc_list(struct net_device *dev)
EXPORT_SYMBOL(com20020_check);
EXPORT_SYMBOL(com20020_found);
EXPORT_SYMBOL(com20020_netdev_ops);
+EXPORT_SYMBOL(com20020_ethtool_ops);
#endif
MODULE_LICENSE("GPL");
diff --git a/drivers/net/arcnet/com20020.h b/drivers/net/arcnet/com20020.h
index af18c7edc4fa..616f047b3661 100644
--- a/drivers/net/arcnet/com20020.h
+++ b/drivers/net/arcnet/com20020.h
@@ -31,6 +31,7 @@
int com20020_check(struct net_device *dev);
int com20020_found(struct net_device *dev, int shared);
extern const struct net_device_ops com20020_netdev_ops;
+extern const struct ethtool_ops com20020_ethtool_ops;
/* The number of low I/O ports used by the card. */
#define ARCNET_TOTAL_SIZE 8
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index bca4e6c15e4f..127aff55794d 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -241,6 +241,7 @@ static int com20020_config(struct pcmcia_device *link)
}
dev->irq = link->irq;
+ dev->ethtool_ops = &com20020_ethtool_ops;
ret = pcmcia_enable_device(link);
if (ret)
diff --git a/include/uapi/linux/if_arcnet.h b/include/uapi/linux/if_arcnet.h
index 683878036d76..790c0fa7386d 100644
--- a/include/uapi/linux/if_arcnet.h
+++ b/include/uapi/linux/if_arcnet.h
@@ -127,4 +127,10 @@ struct archdr {
} soft;
};
+struct com20020_ethtool_regs {
+ __u8 status;
+ __u8 diag_register;
+ __u32 reconf_count;
+};
+
#endif /* _LINUX_IF_ARCNET_H */
--
2.14.4
^ permalink raw reply related
* [PATCH 4/6] arcnet: com20020: bindings for smsc com20020
From: Andrea Greco @ 2018-06-11 14:28 UTC (permalink / raw)
To: davem
Cc: tobin, Andrea Greco, Rob Herring, Mark Rutland, netdev,
devicetree, linux-kernel
From: Andrea Greco <a.greco@4sigma.it>
Add devicetree bindings for smsc com20020
Signed-off-by: Andrea Greco <a.greco@4sigma.it>
---
.../devicetree/bindings/net/smsc-com20020.txt | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/smsc-com20020.txt
diff --git a/Documentation/devicetree/bindings/net/smsc-com20020.txt b/Documentation/devicetree/bindings/net/smsc-com20020.txt
new file mode 100644
index 000000000000..660a4a751f29
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/smsc-com20020.txt
@@ -0,0 +1,21 @@
+SMSC com20020 Arcnet network controller
+
+Required property:
+- timeout-ns: Arcnet bus timeout, Idle Time (328000 - 20500)
+- bus-speed-bps: Arcnet bus speed (10000000 - 156250)
+- smsc,xtal-mhz: External oscillator frequency
+- smsc,backplane-enabled: Controller use backplane mode
+- reset-gpios: Chip reset pin
+- interrupts: Should contain controller interrupt
+
+arcnet@28000000 {
+ compatible = "smsc,com20020";
+
+ timeout-ns = <20500>;
+ bus-speed-hz = <10000000>;
+ smsc,xtal-mhz = <20>;
+ smsc,backplane-enabled;
+
+ reset-gpios = <&gpio3 21 GPIO_ACTIVE_LOW>;
+ interrupts = <&gpio2 10 GPIO_ACTIVE_LOW>;
+};
--
2.14.4
^ permalink raw reply related
* Re: Qualcomm rmnet driver and qmi_wwan
From: Daniele Palmas @ 2018-06-11 14:30 UTC (permalink / raw)
To: Subash Abhinov Kasiviswanathan; +Cc: Bjørn Mork, Dan Williams, netdev
In-Reply-To: <4b74bb1d92b9e9351bc504d18f96116b@codeaurora.org>
Hi Subash,
2018-06-09 19:55 GMT+02:00 Subash Abhinov Kasiviswanathan
<subashab@codeaurora.org>:
>> thanks, I will test it on Monday.
>>
>> Just a question for my knowledge: is the new sysfs attribute really
>> needed? I mean, is there not any other way to understand from qmi_wwan
>> without user intervention that there is the rmnet device attached?
>>
>> Regards,
>> Daniele
>>
>
> Hi Daniele
>
> You can check for the rx_handler attached to qmi_wwan dev and see if it
> belongs to rmnet. You can use the attached patch for it but it think the
> sysfs way might be a bit cleaner.
>
both patches work properly for me.
Maybe it could be helpful in the first patch to add a print when
pass-through setting fails if raw-ip has not been set, just to let the
user know what is happening.
Thanks,
Daniele
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
^ permalink raw reply
* Re: [iproute2-next v2 1/2] tipc: JSON support for showing nametable
From: Stephen Hemminger @ 2018-06-11 15:05 UTC (permalink / raw)
To: Hoang Le; +Cc: netdev, tipc-discussion
In-Reply-To: <1528683420-15006-1-git-send-email-hoang.h.le@dektech.com.au>
On Mon, 11 Jun 2018 09:16:59 +0700
Hoang Le <hoang.h.le@dektech.com.au> wrote:
> @@ -33,6 +35,8 @@ static void about(struct cmdl *cmdl)
> "\n"
> "Options:\n"
> " -h, --help \t\tPrint help for last given command\n"
> + " -j, --json \t\tJson format printouts\n"
> + " -p, --pretty \t\tpretty print\n"
> "\n"
You should also update manual page: man/man8/tipc-nametable.8
Just cut/paste text from ip or tc pages.
^ permalink raw reply
* Re: [PATCH v2 15/24] net: qualcomm: MODULE_DEVICE_TABLE(serdev)
From: Ricardo Ribalda Delgado @ 2018-06-11 15:09 UTC (permalink / raw)
To: Marcel Holtmann
Cc: LKML, open list:SERIAL DRIVERS, Lino Sanfilippo, David Miller,
Stefan Wahren, Rob Herring, Johan Hovold, netdev
In-Reply-To: <CCB7FF79-F89A-4421-A6C0-E0663BEE6065@holtmann.org>
Hi Marcel,
On Mon, Jun 11, 2018 at 3:01 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
>
> the commit message is misleading me. If I build something with ACPI or DT support, then modinfo will show all modalias information for ACPI and DT compatible strings. What else does udev/modprobe actually need? Is something broken with the modalias export?
The main purpose is to autoload drivers for devices that have been
created via sysfs or another module.
Eg1: We have a serial port on a standard computer that has connected a
GPS module. Since it is something that is not in the ACPI nor the DT
table the user will run
echo serdev_gps > /sys/bus/serial/devices/serial0/new_device
Eg2 module: https://github.com/ribalda/linux/blob/415bb3f0076c2b846ebe5409589b8e1e3004f55a/drivers/tty/serdev/test_platform.c
Modprobe does not know what module to load for that device unless
there is a matching MODULE_DEVICE_TABLE
Today, we have the same functionality for i2c devices
https://www.kernel.org/doc/Documentation/i2c/instantiating-devices
I guess the commit message is really bad :), sorry about that. Any
suggestions to improve it?
Thanks!
>
> Regards
>
> Marcel
>
--
Ricardo Ribalda
^ permalink raw reply
* Re: [PATCH net] failover: eliminate callback hell
From: Stephen Hemminger @ 2018-06-11 15:17 UTC (permalink / raw)
To: Siwei Liu
Cc: Samudrala, Sridhar, Michael S. Tsirkin, Jiri Pirko, kys, haiyangz,
David Miller, Netdev, Stephen Hemminger
In-Reply-To: <CADGSJ22LCkzvE-f3KSQDfn8iHKHmE+bh6sRuM9zGx3m0ALExSA@mail.gmail.com>
On Fri, 8 Jun 2018 15:54:38 -0700
Siwei Liu <loseweigh@gmail.com> wrote:
> On Wed, Jun 6, 2018 at 2:54 PM, Samudrala, Sridhar
> <sridhar.samudrala@intel.com> wrote:
> >
> >
> > On 6/6/2018 2:24 PM, Stephen Hemminger wrote:
> >>
> >> On Wed, 6 Jun 2018 15:30:27 +0300
> >> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> >>
> >>> On Wed, Jun 06, 2018 at 09:25:12AM +0200, Jiri Pirko wrote:
> >>>>
> >>>> Tue, Jun 05, 2018 at 05:42:31AM CEST, stephen@networkplumber.org wrote:
> >>>>>
> >>>>> The net failover should be a simple library, not a virtual
> >>>>> object with function callbacks (see callback hell).
> >>>>
> >>>> Why just a library? It should do a common things. I think it should be a
> >>>> virtual object. Looks like your patch again splits the common
> >>>> functionality into multiple drivers. That is kind of backwards attitude.
> >>>> I don't get it. We should rather focus on fixing the mess the
> >>>> introduction of netvsc-bonding caused and switch netvsc to 3-netdev
> >>>> model.
> >>>
> >>> So it seems that at least one benefit for netvsc would be better
> >>> handling of renames.
> >>>
> >>> Question is how can this change to 3-netdev happen? Stephen is
> >>> concerned about risk of breaking some userspace.
> >>>
> >>> Stephen, this seems to be the usecase that IFF_HIDDEN was trying to
> >>> address, and you said then "why not use existing network namespaces
> >>> rather than inventing a new abstraction". So how about it then? Do you
> >>> want to find a way to use namespaces to hide the PV device for netvsc
> >>> compatibility?
> >>>
> >> Netvsc can't work with 3 dev model. MS has worked with enough distro's and
> >> startups that all demand eth0 always be present. And VF may come and go.
> >> After this history, there is a strong motivation not to change how kernel
> >> behaves. Switching to 3 device model would be perceived as breaking
> >> existing userspace.
> >
> >
> > I think it should be possible for netvsc to work with 3 dev model if the
> > only
> > requirement is that eth0 will always be present. With net_failover, you will
> > see eth0 and eth0nsby OR with older distros eth0 and eth1. It may be an
> > issue
> > if somehow there is userspace requirement that there can be only 2 netdevs,
> > not 3
> > when VF is plugged.
> >
> > eth0 will be the net_failover device and eth0nsby/eth1 will be the netvsc
> > device
> > and the IP address gets configured on eth0. Will this be an issue?
> >
> Did you realize that the eth0 name in the current 3-netdev code can't
> be consistently persisted across reboot, if you have more than one VFs
> to pair with? On one boot it got eth0/eth0nsby, on the next it may get
> eth1/eth1nsby on the same interface.
>
> It won't be useable by default until you add some custom udev rules.
>
I think there is no reason to break things by moving netvsc to 3 device
model.
The first device probed is always the same on Hyper-V/Azure, and always
comes up as eth0. The order comes from the fact that they are reported
to guest in that order and currently vmbus probe is single threaded.
^ permalink raw reply
* Re: [PATCH net] failover: eliminate callback hell
From: Stephen Hemminger @ 2018-06-11 15:22 UTC (permalink / raw)
To: Siwei Liu
Cc: Michael S. Tsirkin, Jiri Pirko, kys, haiyangz, David Miller,
Samudrala, Sridhar, Netdev, Stephen Hemminger
In-Reply-To: <CADGSJ22Fok88EY+vgU-i5HVsyJNdS5g5Oe1W3vvNy7_q+2_2HA@mail.gmail.com>
On Fri, 8 Jun 2018 17:42:21 -0700
Siwei Liu <loseweigh@gmail.com> wrote:
> On Fri, Jun 8, 2018 at 5:02 PM, Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> > On Fri, 8 Jun 2018 16:44:12 -0700
> > Siwei Liu <loseweigh@gmail.com> wrote:
> >
> >> On Fri, Jun 8, 2018 at 4:18 PM, Stephen Hemminger
> >> <stephen@networkplumber.org> wrote:
> >> > On Fri, 8 Jun 2018 15:25:59 -0700
> >> > Siwei Liu <loseweigh@gmail.com> wrote:
> >> >
> >> >> On Wed, Jun 6, 2018 at 2:24 PM, Stephen Hemminger
> >> >> <stephen@networkplumber.org> wrote:
> >> >> > On Wed, 6 Jun 2018 15:30:27 +0300
> >> >> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> >> >> >
> >> >> >> On Wed, Jun 06, 2018 at 09:25:12AM +0200, Jiri Pirko wrote:
> >> >> >> > Tue, Jun 05, 2018 at 05:42:31AM CEST, stephen@networkplumber.org wrote:
> >> >> >> > >The net failover should be a simple library, not a virtual
> >> >> >> > >object with function callbacks (see callback hell).
> >> >> >> >
> >> >> >> > Why just a library? It should do a common things. I think it should be a
> >> >> >> > virtual object. Looks like your patch again splits the common
> >> >> >> > functionality into multiple drivers. That is kind of backwards attitude.
> >> >> >> > I don't get it. We should rather focus on fixing the mess the
> >> >> >> > introduction of netvsc-bonding caused and switch netvsc to 3-netdev
> >> >> >> > model.
> >> >> >>
> >> >> >> So it seems that at least one benefit for netvsc would be better
> >> >> >> handling of renames.
> >> >> >>
> >> >> >> Question is how can this change to 3-netdev happen? Stephen is
> >> >> >> concerned about risk of breaking some userspace.
> >> >> >>
> >> >> >> Stephen, this seems to be the usecase that IFF_HIDDEN was trying to
> >> >> >> address, and you said then "why not use existing network namespaces
> >> >> >> rather than inventing a new abstraction". So how about it then? Do you
> >> >> >> want to find a way to use namespaces to hide the PV device for netvsc
> >> >> >> compatibility?
> >> >> >>
> >> >> >
> >> >> > Netvsc can't work with 3 dev model. MS has worked with enough distro's and
> >> >> > startups that all demand eth0 always be present. And VF may come and go.
> >> >> > After this history, there is a strong motivation not to change how kernel
> >> >> > behaves. Switching to 3 device model would be perceived as breaking
> >> >> > existing userspace.
> >> >> >
> >> >> > With virtio you can work it out with the distro's yourself.
> >> >> > There is no pre-existing semantics to deal with.
> >> >> >
> >> >> > For the virtio, I don't see the need for IFF_HIDDEN.
> >> >>
> >> >> I have a somewhat different view regarding IFF_HIDDEN. The purpose of
> >> >> that flag, as well as the 1-netdev model, is to have a means to
> >> >> inherit the interface name from the VF, and to eliminate playing hacks
> >> >> around renaming devices, customizing udev rules and et al. Why
> >> >> inheriting VF's name important? To allow existing config/setup around
> >> >> VF continues to work across kernel feature upgrade. Most of network
> >> >> config files in all distros are based on interface names. Few are MAC
> >> >> address based but making lower slaves hidden would cover the rest. And
> >> >> most importantly, preserving the same level of user experience as
> >> >> using raw VF interface once getting all ndo_ops and ethtool_ops
> >> >> exposed. This is essential to realize transparent live migration that
> >> >> users dont have to learn and be aware of the undertaken.
> >> >
> >> > Inheriting the VF name will fail in the migration scenario.
> >> > It is perfectly reasonable to migrate a guest to another machine where
> >> > the VF PCI address is different. And since current udev/systemd model
> >> > is to base network device name off of PCI address, the device will change
> >> > name when guest is migrated.
> >> >
> >> The scenario of having VF on a different PCI address on post migration
> >> is essentially equal to plugging in a new NIC. Why it has to pair with
> >> the original PV? A sepearte PV device should be in place to pair the
> >> new VF.
> >
> > The host only guarantees that the PV device will be on the same network.
> > It does not make any PCI guarantees. The way Windows works is to find
> > the device based on "serial number" which is an Hyper-V specific attribute
> > of PCI devices.
> >
> > I considered naming off of serial number but that won't work for the
> > case where PV device is present first and VF arrives later. The serial
> > number is attribute of VF, not the PV which is there first.
>
> I assume the PV can get that information ahead of time before VF
> arrives? Without it how do you match the device when you see a VF
> coming with some serial number? Is it possible for PV to get the
> matching SN even earlier during probe time? Or it has to depend on the
> presence of vPCI bridge to generate this SN?
NO. the PV device does not know ahead of time and there are scenario
where the serial and PCI info can change when it does arrive. These
are test cases (not something people usually do). Example on WS2016:
Guest configured with two or more vswitches and NICs.
SR-IOV is not enabled
Later:
On Hyper-V console (or Powershell command line) on host SR-IOV
is enabled on the second NIC.
The guest will be notified of new PCI device; the "serial number"
will be 1.
If same process is repeated but in this case the first NIC has
SR-IOV enabled, it will get serial # 1.
I agree with Jakub. What you are proposing is backwards. The VF
must be thought of as a dependent of PV device not vice/versa.
> >
> > Your ideas about having the PCI information of the VF form the name
> > of the failover device have the same problem. The PV device may
> > be the only one present on boot.
>
> Yeah, this is a chicken-egg problem indeed, and that was the reason
> why I supply the BDF info for PV to name the master interface.
> However, the ACPI PCI slot needs to depend on the PCI bus enumeration
> so that can't be predictable. Would it make sense to only rename when
> the first time a matching VF appears and PV interface isn't brought
> up, then the failover master would always stick to the name
> afterwards? I think it should cover most scenarios as it's usually
> during boot time (dracut) the VF first appears and the PV interface at
> the time then shouldn't have been configured yet.
>
> -Siwei
>
> >
> >
> >> > On Azure, the VF maybe removed (by host) at any time and then later
> >> > reattached. There is no guarantee that VF will show back up at
> >> > the same synthetic PCI address. It will likely have a different
> >> > PCI domain value.
> >>
> >> This is something QEMU can do and make sure the PCI address is
> >> consistent after migration.
> >>
> >> -Siwei
> >
^ permalink raw reply
* Re: [PATCH v2 15/24] net: qualcomm: MODULE_DEVICE_TABLE(serdev)
From: Marcel Holtmann @ 2018-06-11 15:28 UTC (permalink / raw)
To: Ricardo Ribalda Delgado
Cc: LKML, open list:SERIAL DRIVERS, Lino Sanfilippo, David S. Miller,
Stefan Wahren, Rob Herring, Johan Hovold, netdev
In-Reply-To: <CAPybu_0=ykAcCx=nZyrv90YRfihDxi3s2+Nz+6UP8Fwd5eH2-A@mail.gmail.com>
Hi Marcel,
>> the commit message is misleading me. If I build something with ACPI or DT support, then modinfo will show all modalias information for ACPI and DT compatible strings. What else does udev/modprobe actually need? Is something broken with the modalias export?
>
> The main purpose is to autoload drivers for devices that have been
> created via sysfs or another module.
>
> Eg1: We have a serial port on a standard computer that has connected a
> GPS module. Since it is something that is not in the ACPI nor the DT
> table the user will run
>
> echo serdev_gps > /sys/bus/serial/devices/serial0/new_device
>
> Eg2 module: https://github.com/ribalda/linux/blob/415bb3f0076c2b846ebe5409589b8e1e3004f55a/drivers/tty/serdev/test_platform.c
>
> Modprobe does not know what module to load for that device unless
> there is a matching MODULE_DEVICE_TABLE
> Today, we have the same functionality for i2c devices
> https://www.kernel.org/doc/Documentation/i2c/instantiating-devices
but why does this have to be the driver name? I would rather say, create a generic string that describes the hardware and then use that. I think you also want the special handling, as from USB for example, that lets you reference an existing .compatible or ACPI ID as reference so that the driver_data is copied.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v2 15/24] net: qualcomm: MODULE_DEVICE_TABLE(serdev)
From: Ricardo Ribalda Delgado @ 2018-06-11 15:33 UTC (permalink / raw)
To: Marcel Holtmann
Cc: LKML, open list:SERIAL DRIVERS, Lino Sanfilippo, David Miller,
Stefan Wahren, Rob Herring, Johan Hovold, netdev
In-Reply-To: <B4BC9DB0-2D7C-4F9D-99FE-8227D4DC3D54@holtmann.org>
Hi Marcel,
On Mon, Jun 11, 2018 at 5:28 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Marcel,
>
> >> the commit message is misleading me. If I build something with ACPI or DT support, then modinfo will show all modalias information for ACPI and DT compatible strings. What else does udev/modprobe actually need? Is something broken with the modalias export?
> >
> > The main purpose is to autoload drivers for devices that have been
> > created via sysfs or another module.
> >
> > Eg1: We have a serial port on a standard computer that has connected a
> > GPS module. Since it is something that is not in the ACPI nor the DT
> > table the user will run
> >
> > echo serdev_gps > /sys/bus/serial/devices/serial0/new_device
> >
> > Eg2 module: https://github.com/ribalda/linux/blob/415bb3f0076c2b846ebe5409589b8e1e3004f55a/drivers/tty/serdev/test_platform.c
> >
> > Modprobe does not know what module to load for that device unless
> > there is a matching MODULE_DEVICE_TABLE
> > Today, we have the same functionality for i2c devices
> > https://www.kernel.org/doc/Documentation/i2c/instantiating-devices
>
> but why does this have to be the driver name? I would rather say, create a generic string that describes the hardware and then use that. I think you also want the special handling, as from USB for example, that lets you reference an existing .compatible or ACPI ID as reference so that the driver_data is copied.
We can choose any name, but if there are no special variants (like the
rave-sp driver) I would prefer using the module name. We can of course
use more names, like the part number of the the device, but it is very
convenient to also use the module name, and other subsystems also do
that.
If you want to add specific names for this device please let me know
and I will add them to the list. You know much more about this module
than myself.
Thanks!
>
> Regards
>
> Marcel
>
--
Ricardo Ribalda
^ permalink raw reply
* Re: [PATCH] Bluetooth: hci_bcm: Configure SCO routing automatically
From: Rob Herring @ 2018-06-11 15:34 UTC (permalink / raw)
To: Attila Tőkés
Cc: David S. Miller, Mark Rutland, Marcel Holtmann, Johan Hedberg,
Artiom Vaskov, netdev, devicetree, linux-kernel@vger.kernel.org,
open list:BLUETOOTH DRIVERS
In-Reply-To: <CAMoM21HshLyv+Np1vOKYTAunsPCazyP-WESiaheNXHsC078S8g@mail.gmail.com>
On Sat, Jun 9, 2018 at 12:26 AM, Attila Tőkés <attitokes@gmail.com> wrote:
> Hello Rob,
>
> On Fri, Jun 8, 2018 at 8:25 PM, Rob Herring <robh+dt@kernel.org> wrote:
>>
>> On Fri, Jun 8, 2018 at 10:20 AM, <attitokes@gmail.com> wrote:
>> > From: Attila Tőkés <attitokes@gmail.com>
>> >
>> > Added support to automatically configure the SCO packet routing at the
>> > device setup. The SCO packets are used with the HSP / HFP profiles, but in
>> > some devices (ex. CYW43438) they are routed to a PCM output by default. This
>> > change allows sending the vendor specific HCI command to configure the SCO
>> > routing. The parameters of the command are loaded from the device tree.
>>
>> Please wrap your commit msg.
>
>
> Sure.
>>
>>
>> >
>> > Signed-off-by: Attila Tőkés <attitokes@gmail.com>
>> > ---
>> > .../bindings/net/broadcom-bluetooth.txt | 7 ++
>>
>> Please split bindings to separate patch.
>
>
> Ok, I will split this in two.
>>
>>
>>
>>
>> > drivers/bluetooth/hci_bcm.c | 72 +++++++++++++++++++
>> > 2 files changed, 79 insertions(+)
>> >
>> > diff --git
>> > a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>> > b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>> > index 4194ff7e..aea3a094 100644
>> > --- a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>> > +++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>> > @@ -21,6 +21,12 @@ Optional properties:
>> > - clocks: clock specifier if external clock provided to the controller
>> > - clock-names: should be "extclk"
>> >
>> > + SCO routing parameters:
>> > + - sco-routing: 0-3 (PCM, Transport, Codec, I2S)
>> > + - pcm-interface-rate: 0-4 (128 Kbps - 2048 Kbps)
>> > + - pcm-frame-type: 0 (short), 1 (long)
>> > + - pcm-sync-mode: 0 (slave), 1 (master)
>> > + - pcm-clock-mode: 0 (slave), 1 (master)
>>
>> Are these Broadcom specific? Properties need either vendor prefix or
>> to be documented in a common location. I think these look like the
>> latter.
>
>
> These will be used as parameters of a vendor specific (Broadcom/Cypress)
> command configuring the SCO packet routing. See the Write_SCO_PCM_Int_Param
> command from: http://www.cypress.com/file/298311/download.
The DT should just describe how the h/w is hooked-up. What the s/w has
to do based on that is the driver's problem which is certainly
vendor/chip specific, but that is all irrelevant to the binding.
> What would be the property names with a Broadcom / Cypress vendor prefix?
>
> brcm,sco-routing
> brcm,pcm-interface-rate
> brcm,pcm-frame-type
> brcm,pcm-sync-mode
> brcm,pcm-clock-mode
>
> ?
Yes.
>
>>
>>
>> However, this also looks incomplete to me. For example, which SoC
>> I2S/PCM port is BT audio connected to and how does it fit into the
>> existing audio related bindings? There's been work on HDMI audio
>> bindings which would be similar (except for the SCO over UART at
>> least).
>
>
> The I2S / PCM pins of the Bluetooth chip most likely will not be connected
> to the host SoC. When used with a SoC we probably want tor route the SCO
> packets over the UART transport. A2DP data already goes here and we probably
> want the same for HSP / HFP.
Then that should be the default with no properties.
I imagine for phones, vendors want I2S hooked up for voice calls so
audio can be routed directly to/from the modem and the power hungry
apps processor can be kept in low power modes.
> For example in the Raspberry Pi 3 B, the CYW43438's PCM output is not
> connected (there is no I2S output), But it may be connected to any other
> device in other hardware.
>
> The purpose of this command is to tell the BT chip where to send the SCO
> packets. From the driver's perspective, it does not really matters where
> these pins are connected.
Bindings are for h/w description (and config to some extent).
>> > Example:
>> >
>> > @@ -31,5 +37,6 @@ Example:
>> > bluetooth {
>> > compatible = "brcm,bcm43438-bt";
>> > max-speed = <921600>;
>> > + sco-routing = <1>; /* 1 = transport (UART) */
>> > };
>> > };
>> > diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
>> > index ddbd8c6a..0e729534 100644
>> > --- a/drivers/bluetooth/hci_bcm.c
>> > +++ b/drivers/bluetooth/hci_bcm.c
>> > @@ -83,6 +83,16 @@
>> > * @hu: pointer to HCI UART controller struct,
>> > * used to disable flow control during runtime suspend and system
>> > sleep
>> > * @is_suspended: whether flow control is currently disabled
>> > + *
>> > + * SCO routing parameters:
>> > + * used as the parameters for the bcm_set_pcm_int_params command
>> > + * @sco_routing:
>> > + * >= 255 (skip SCO routing configuration)
>> > + * 0-3 (PCM, Transport, Codec, I2S)
>> > + * @pcm_interface_rate: 0-4 (128 Kbps - 2048 Kbps)
>> > + * @pcm_frame_type: 0 (short), 1 (long)
>> > + * @pcm_sync_mode: 0 (slave), 1 (master)
>> > + * @pcm_clock_mode: 0 (slave), 1 (master)
>> > */
>> > struct bcm_device {
>> > /* Must be the first member, hci_serdev.c expects this. */
>> > @@ -114,6 +124,13 @@ struct bcm_device {
>> > struct hci_uart *hu;
>> > bool is_suspended;
>> > #endif
>> > +
>> > + /* SCO routing parameters */
>> > + u8 sco_routing;
>> > + u8 pcm_interface_rate;
>> > + u8 pcm_frame_type;
>> > + u8 pcm_sync_mode;
>> > + u8 pcm_clock_mode;
>> > };
>> >
>> > /* generic bcm uart resources */
>> > @@ -189,6 +206,40 @@ static int bcm_set_baudrate(struct hci_uart *hu,
>> > unsigned int speed)
>> > return 0;
>> > }
>> >
>> > +static int bcm_configure_sco_routing(struct hci_uart *hu, struct
>> > bcm_device *bcm_dev)
>> > +{
>> > + struct hci_dev *hdev = hu->hdev;
>> > + struct sk_buff *skb;
>> > + struct bcm_set_pcm_int_params params;
>> > +
>> > + if (bcm_dev->sco_routing >= 0xff) {
>> > + /* SCO routing configuration should be skipped */
>> > + return 0;
>> > + }
>> > +
>> > + bt_dev_dbg(hdev, "BCM: Configuring SCO routing (%d %d %d %d
>> > %d)",
>> > + bcm_dev->sco_routing,
>> > bcm_dev->pcm_interface_rate, bcm_dev->pcm_frame_type,
>> > + bcm_dev->pcm_sync_mode,
>> > bcm_dev->pcm_clock_mode);
>> > +
>> > + params.routing = bcm_dev->sco_routing;
>> > + params.rate = bcm_dev->pcm_interface_rate;
>> > + params.frame_sync = bcm_dev->pcm_frame_type;
>> > + params.sync_mode = bcm_dev->pcm_sync_mode;
>> > + params.clock_mode = bcm_dev->pcm_clock_mode;
>> > +
>> > + /* Send the SCO routing configuration command */
>> > + skb = __hci_cmd_sync(hdev, 0xfc1c, sizeof(params), ¶ms,
>> > HCI_CMD_TIMEOUT);
>> > + if (IS_ERR(skb)) {
>> > + int err = PTR_ERR(skb);
>> > + bt_dev_err(hdev, "BCM: failed to configure SCO routing
>> > (%d)", err);
>> > + return err;
>> > + }
>> > +
>> > + kfree_skb(skb);
>> > +
>> > + return 0;
>> > +}
>> > +
>> > /* bcm_device_exists should be protected by bcm_device_lock */
>> > static bool bcm_device_exists(struct bcm_device *device)
>> > {
>> > @@ -534,6 +585,9 @@ static int bcm_setup(struct hci_uart *hu)
>> > host_set_baudrate(hu, speed);
>> > }
>> >
>> > + /* Configure SCO routing if needed */
>> > + bcm_configure_sco_routing(hu, bcm->dev);
>> > +
>> > finalize:
>> > release_firmware(fw);
>> >
>> > @@ -1004,9 +1058,21 @@ static int bcm_acpi_probe(struct bcm_device *dev)
>> > }
>> > #endif /* CONFIG_ACPI */
>> >
>> > +static void read_u8_device_property(struct device *device, const char
>> > *property, u8 *destination) {
>> > + u32 temp;
>> > + if (device_property_read_u32(device, property, &temp) == 0) {
>> > + *destination = temp & 0xff;
>> > + }
>> > +}
>> > +
>> > static int bcm_of_probe(struct bcm_device *bdev)
>> > {
>> > device_property_read_u32(bdev->dev, "max-speed",
>> > &bdev->oper_speed);
>> > + read_u8_device_property(bdev->dev, "sco-routing",
>> > &bdev->sco_routing);
>> > + read_u8_device_property(bdev->dev, "pcm-interface-rate",
>> > &bdev->pcm_interface_rate);
>> > + read_u8_device_property(bdev->dev, "pcm-frame-type",
>> > &bdev->pcm_frame_type);
>> > + read_u8_device_property(bdev->dev, "pcm-sync-mode",
>> > &bdev->pcm_sync_mode);
>> > + read_u8_device_property(bdev->dev, "pcm-clock-mode",
>> > &bdev->pcm_clock_mode);
>>
>> These are actually broken because the DT properties are 32-bit.
>>
> The properties from device tree are read as 32-bit values, then they are
> truncated to 8-bit (see the read_u8_device_property function above). Is
> anything wrong with this?
Ah, NM, I missed the wrapper.
Rob
^ permalink raw reply
* Re: [PATCH] Bluetooth: hci_bcm: Configure SCO routing automatically
From: Marcel Holtmann @ 2018-06-11 15:47 UTC (permalink / raw)
To: Rob Herring
Cc: Attila Tőkés, David S. Miller, Mark Rutland,
Johan Hedberg, Artiom Vaskov, netdev, devicetree,
linux-kernel@vger.kernel.org, open list:BLUETOOTH DRIVERS
In-Reply-To: <CAL_Jsq+a93Rpf3UAPBQ5QmA8KavberGXz76WCiZ7feHH5GgcDA@mail.gmail.com>
Hi Rob,
>>>> Added support to automatically configure the SCO packet routing at the
>>>> device setup. The SCO packets are used with the HSP / HFP profiles, but in
>>>> some devices (ex. CYW43438) they are routed to a PCM output by default. This
>>>> change allows sending the vendor specific HCI command to configure the SCO
>>>> routing. The parameters of the command are loaded from the device tree.
>>>
>>> Please wrap your commit msg.
>>
>>
>> Sure.
>>>
>>>
>>>>
>>>> Signed-off-by: Attila Tőkés <attitokes@gmail.com>
>>>> ---
>>>> .../bindings/net/broadcom-bluetooth.txt | 7 ++
>>>
>>> Please split bindings to separate patch.
>>
>>
>> Ok, I will split this in two.
>>>
>>>
>>>
>>>
>>>> drivers/bluetooth/hci_bcm.c | 72 +++++++++++++++++++
>>>> 2 files changed, 79 insertions(+)
>>>>
>>>> diff --git
>>>> a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>>>> b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>>>> index 4194ff7e..aea3a094 100644
>>>> --- a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>>>> +++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
>>>> @@ -21,6 +21,12 @@ Optional properties:
>>>> - clocks: clock specifier if external clock provided to the controller
>>>> - clock-names: should be "extclk"
>>>>
>>>> + SCO routing parameters:
>>>> + - sco-routing: 0-3 (PCM, Transport, Codec, I2S)
>>>> + - pcm-interface-rate: 0-4 (128 Kbps - 2048 Kbps)
>>>> + - pcm-frame-type: 0 (short), 1 (long)
>>>> + - pcm-sync-mode: 0 (slave), 1 (master)
>>>> + - pcm-clock-mode: 0 (slave), 1 (master)
>>>
>>> Are these Broadcom specific? Properties need either vendor prefix or
>>> to be documented in a common location. I think these look like the
>>> latter.
>>
>>
>> These will be used as parameters of a vendor specific (Broadcom/Cypress)
>> command configuring the SCO packet routing. See the Write_SCO_PCM_Int_Param
>> command from: http://www.cypress.com/file/298311/download.
>
> The DT should just describe how the h/w is hooked-up. What the s/w has
> to do based on that is the driver's problem which is certainly
> vendor/chip specific, but that is all irrelevant to the binding.
>
>> What would be the property names with a Broadcom / Cypress vendor prefix?
>>
>> brcm,sco-routing
>> brcm,pcm-interface-rate
>> brcm,pcm-frame-type
>> brcm,pcm-sync-mode
>> brcm,pcm-clock-mode
>>
>> ?
>
> Yes.
we can do this. However all pcm-* are optional if you switch the HCI transport. And sco-routing should default to HCI if that is not present. Meaning a driver should actively trying to change this. Nevertheless, it would be good if a driver reads the current settings.
In theory we could make sco-routing generic, but so many vendors have different modes, that we better keep this vendor specific.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v2 15/24] net: qualcomm: MODULE_DEVICE_TABLE(serdev)
From: Marcel Holtmann @ 2018-06-11 15:52 UTC (permalink / raw)
To: Ricardo Ribalda Delgado
Cc: LKML, open list:SERIAL DRIVERS, Lino Sanfilippo, David S. Miller,
Stefan Wahren, Rob Herring, Johan Hovold, netdev
In-Reply-To: <CAPybu_2ViGvN6egz-Ajq4+1fv6VAVFswuvSPAVmYH0a9R-Yjvw@mail.gmail.com>
Hi Ricardo,
>>>> the commit message is misleading me. If I build something with ACPI or DT support, then modinfo will show all modalias information for ACPI and DT compatible strings. What else does udev/modprobe actually need? Is something broken with the modalias export?
>>>
>>> The main purpose is to autoload drivers for devices that have been
>>> created via sysfs or another module.
>>>
>>> Eg1: We have a serial port on a standard computer that has connected a
>>> GPS module. Since it is something that is not in the ACPI nor the DT
>>> table the user will run
>>>
>>> echo serdev_gps > /sys/bus/serial/devices/serial0/new_device
>>>
>>> Eg2 module: https://github.com/ribalda/linux/blob/415bb3f0076c2b846ebe5409589b8e1e3004f55a/drivers/tty/serdev/test_platform.c
>>>
>>> Modprobe does not know what module to load for that device unless
>>> there is a matching MODULE_DEVICE_TABLE
>>> Today, we have the same functionality for i2c devices
>>> https://www.kernel.org/doc/Documentation/i2c/instantiating-devices
>>
>> but why does this have to be the driver name? I would rather say, create a generic string that describes the hardware and then use that. I think you also want the special handling, as from USB for example, that lets you reference an existing .compatible or ACPI ID as reference so that the driver_data is copied.
>
> We can choose any name, but if there are no special variants (like the
> rave-sp driver) I would prefer using the module name. We can of course
> use more names, like the part number of the the device, but it is very
> convenient to also use the module name, and other subsystems also do
> that.
>
> If you want to add specific names for this device please let me know
> and I will add them to the list. You know much more about this module
> than myself.
if we want to use the driver name, then why not build this into the new_device handling itself instead of duplicating that name in each serdev_device_id table. What is the reference here? For example platform device do matching on driver name if I recall this correctly.
However what is most important is that device_get_match_data() actually works. There should be no difference between DT, ACPI or a dynamic device.
Regards
Marcel
^ permalink raw reply
* locking in wimax/i2400m
From: Sebastian Andrzej Siewior @ 2018-06-11 16:05 UTC (permalink / raw)
To: Inaky Perez-Gonzalez, linux-wimax; +Cc: netdev, tglx
I tried to figure out if the URB-completion handler uses any locking and
stumbled here.
i2400m_pm_notifier() is called from process context. This function
invokes i2400m_fw_cache() + i2400m_fw_uncache(). Both functions do
spin_lock(&i2400m->rx_lock);
while in other places (say i2400mu_rxd()) it does
spin_lock_irqsave(&i2400m->rx_lock, flags);
So what do I miss? Is this lock never used in interrupt context and
lockdep didn't complain or did nobody try suspend with this driver
before?
>From what I can tell i2400m_dev_bootstrap() has the same locking
problem.
While here, I noticed that i2400m_fw_cache() does use GFP_ATOMIC which
should be GFP_KERNEL since the context can't be atomic at this point
(there is even request_firmware() later on).
I am also curious why there is NULL and ~0 because it does not seem to
make a difference in i2400m_fw_uncache() but I'm more interested in
the locking bits :)
Sebastian
^ permalink raw reply
* Re: [PATCH net] ipv6: allow PMTU exceptions to local routes
From: Martin KaFai Lau @ 2018-06-11 16:07 UTC (permalink / raw)
To: Julian Anastasov; +Cc: David Miller, netdev, kernel-team, lvs-devel
In-Reply-To: <20180610230254.6347-1-ja@ssi.bg>
On Mon, Jun 11, 2018 at 02:02:54AM +0300, Julian Anastasov wrote:
> IPVS setups with local client and remote tunnel server need
> to create exception for the local virtual IP. What we do is to
> change PMTU from 64KB (on "lo") to 1460 in the common case.
>
> Suggested-by: Martin KaFai Lau <kafai@fb.com>
> Fixes: 45e4fd26683c ("ipv6: Only create RTF_CACHE routes after encountering pmtu exception")
> Fixes: 7343ff31ebf0 ("ipv6: Don't create clones of host routes.")
> Signed-off-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply
* [net 0/5][pull request] Intel Wired LAN Driver Updates 2018-06-11
From: Jeff Kirsher @ 2018-06-11 16:16 UTC (permalink / raw)
To: davem; +Cc: Jeff Kirsher, netdev, nhorman, sassmann, jogreene
This series contains fixes to ixgbe IPsec and MACVLAN.
Alex provides the 5 fixes in this series, starting with fixing an issue
where num_rx_pools was not being populated until after the queues and
interrupts were reinitialized when enabling MACVLAN interfaces. Updated
to use CONFIG_XFRM_OFFLOAD instead of CONFIG_XFRM, since the code
requires CONFIG_XFRM_OFFLOAD to be enabled. Moved the IPsec
initialization function to be more consistent with the placement of
similar initialization functions and before the call to reset the
hardware, which will clean up any link issues that may have been
introduced. Fixed the boolean logic that was testing for transmit OR
receive ready bits, when it should have been testing for transmit AND
receive ready bits. Fixed the bit definitions for SECTXSTAT and SECRXSTAT
registers and ensure that if IPsec is disabled on the part, do not
enable it.
The following are changes since commit f0dc7f9c6dd99891611fca5849cbc4c6965b690e:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue 10GbE
Alexander Duyck (5):
ixgbe: Fix setting of TC configuration for macvlan case
ixgbe: Use CONFIG_XFRM_OFFLOAD instead of CONFIG_XFRM
ixgbe: Move ipsec init function to before reset call
ixgbe: Avoid loopback and fix boolean logic in ipsec_stop_data
ixgbe: Fix bit definitions and add support for testing for ipsec
support
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 4 +--
.../net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 34 +++++++++++++------
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 8 +++++
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 21 ++++++------
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 6 ++--
5 files changed, 48 insertions(+), 25 deletions(-)
--
2.17.1
^ permalink raw reply
* [net 1/5] ixgbe: Fix setting of TC configuration for macvlan case
From: Jeff Kirsher @ 2018-06-11 16:16 UTC (permalink / raw)
To: davem
Cc: Alexander Duyck, netdev, nhorman, sassmann, jogreene, stable,
Jeff Kirsher
In-Reply-To: <20180611161630.21338-1-jeffrey.t.kirsher@intel.com>
From: Alexander Duyck <alexander.h.duyck@intel.com>
When we were enabling macvlan interfaces we weren't correctly configuring
things until ixgbe_setup_tc was called a second time either by tweaking the
number of queues or increasing the macvlan count past 15.
The issue came down to the fact that num_rx_pools is not populated until
after the queues and interrupts are reinitialized.
Instead of trying to set it sooner we can just move the call to setup at
least 1 traffic class to the SR-IOV/VMDq setup function so that we just set
it for this one case. We already had a spot that was configuring the queues
for TC 0 in the code here anyway so it makes sense to also set the number
of TCs here as well.
CC: stable <stable@vger.kernel.org>
Fixes: 49cfbeb7a95c ("ixgbe: Fix handling of macvlan Tx offload")
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 8 ++++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 --------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
index 893a9206e718..d361f570ca37 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
@@ -593,6 +593,14 @@ static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
}
#endif
+ /* To support macvlan offload we have to use num_tc to
+ * restrict the queues that can be used by the device.
+ * By doing this we can avoid reporting a false number of
+ * queues.
+ */
+ if (vmdq_i > 1)
+ netdev_set_num_tc(adapter->netdev, 1);
+
/* populate TC0 for use by pool 0 */
netdev_set_tc_queue(adapter->netdev, 0,
adapter->num_rx_queues_per_pool, 0);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 4929f7265598..f9e0dc041cfb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -8822,14 +8822,6 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
} else {
netdev_reset_tc(dev);
- /* To support macvlan offload we have to use num_tc to
- * restrict the queues that can be used by the device.
- * By doing this we can avoid reporting a false number of
- * queues.
- */
- if (!tc && adapter->num_rx_pools > 1)
- netdev_set_num_tc(dev, 1);
-
if (adapter->hw.mac.type == ixgbe_mac_82598EB)
adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
--
2.17.1
^ permalink raw reply related
* [net 2/5] ixgbe: Use CONFIG_XFRM_OFFLOAD instead of CONFIG_XFRM
From: Jeff Kirsher @ 2018-06-11 16:16 UTC (permalink / raw)
To: davem
Cc: Alexander Duyck, netdev, nhorman, sassmann, jogreene, stable,
Jeff Kirsher
In-Reply-To: <20180611161630.21338-1-jeffrey.t.kirsher@intel.com>
From: Alexander Duyck <alexander.h.duyck@intel.com>
There is no point in adding code if CONFIG_XFRM is defined that we won't
use unless CONFIG_XFRM_OFFLOAD is defined. So instead of leaving this code
floating around I am replacing the ifdef with what I believe is the correct
one so that we only include the code and variables if they will actually be
used.
CC: stable <stable@vger.kernel.org>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@oracle.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 4 ++--
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index fc534e91c6b2..144d5fe6b944 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -760,9 +760,9 @@ struct ixgbe_adapter {
#define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */
u32 *rss_key;
-#ifdef CONFIG_XFRM
+#ifdef CONFIG_XFRM_OFFLOAD
struct ixgbe_ipsec *ipsec;
-#endif /* CONFIG_XFRM */
+#endif /* CONFIG_XFRM_OFFLOAD */
};
static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index f9e0dc041cfb..a925f05ec342 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -9896,7 +9896,7 @@ ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
* the TSO, so it's the exception.
*/
if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) {
-#ifdef CONFIG_XFRM
+#ifdef CONFIG_XFRM_OFFLOAD
if (!skb->sp)
#endif
features &= ~NETIF_F_TSO;
--
2.17.1
^ permalink raw reply related
* [net 3/5] ixgbe: Move ipsec init function to before reset call
From: Jeff Kirsher @ 2018-06-11 16:16 UTC (permalink / raw)
To: davem
Cc: Alexander Duyck, netdev, nhorman, sassmann, jogreene, stable,
Jeff Kirsher
In-Reply-To: <20180611161630.21338-1-jeffrey.t.kirsher@intel.com>
From: Alexander Duyck <alexander.h.duyck@intel.com>
This patch moves the IPsec init function in ixgbe_sw_init. This way it is a
bit more consistent with the placement of similar initialization functions
and is placed before the reset_hw call which should allow us to clean up
any link issues that may be introduced by the fact that we force the link
up if somehow the device had IPsec still enabled before the driver was
loaded.
In addition to the function move it is necessary to change the assignment
of netdev->features. The easiest way to do this is to just test for the
existence of adapter->ipsec and if it is present we set the feature bits.
CC: stable <stable@vger.kernel.org>
Fixes: 49a94d74d948 ("ixgbe: add ipsec engine start and stop routines")
Reported-by: Andre Tomt <andre@tomt.net>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@oracle.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 7 -------
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 11 +++++++++--
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 344a1f213a5f..38d8cf75e9ad 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -1001,13 +1001,6 @@ void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter)
adapter->netdev->xfrmdev_ops = &ixgbe_xfrmdev_ops;
-#define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \
- NETIF_F_HW_ESP_TX_CSUM | \
- NETIF_F_GSO_ESP)
-
- adapter->netdev->features |= IXGBE_ESP_FEATURES;
- adapter->netdev->hw_enc_features |= IXGBE_ESP_FEATURES;
-
return;
err2:
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index a925f05ec342..8d061af276d3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6117,6 +6117,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,
#ifdef CONFIG_IXGBE_DCB
ixgbe_init_dcb(adapter);
#endif
+ ixgbe_init_ipsec_offload(adapter);
/* default flow control settings */
hw->fc.requested_mode = ixgbe_fc_full;
@@ -10429,6 +10430,14 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (hw->mac.type >= ixgbe_mac_82599EB)
netdev->features |= NETIF_F_SCTP_CRC;
+#ifdef CONFIG_XFRM_OFFLOAD
+#define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \
+ NETIF_F_HW_ESP_TX_CSUM | \
+ NETIF_F_GSO_ESP)
+
+ if (adapter->ipsec)
+ netdev->features |= IXGBE_ESP_FEATURES;
+#endif
/* copy netdev features into list of user selectable features */
netdev->hw_features |= netdev->features |
NETIF_F_HW_VLAN_CTAG_FILTER |
@@ -10491,8 +10500,6 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
NETIF_F_FCOE_MTU;
}
#endif /* IXGBE_FCOE */
- ixgbe_init_ipsec_offload(adapter);
-
if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)
netdev->hw_features |= NETIF_F_LRO;
if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
--
2.17.1
^ permalink raw reply related
* [net 4/5] ixgbe: Avoid loopback and fix boolean logic in ipsec_stop_data
From: Jeff Kirsher @ 2018-06-11 16:16 UTC (permalink / raw)
To: davem
Cc: Alexander Duyck, netdev, nhorman, sassmann, jogreene, stable,
Jeff Kirsher
In-Reply-To: <20180611161630.21338-1-jeffrey.t.kirsher@intel.com>
From: Alexander Duyck <alexander.h.duyck@intel.com>
This patch fixes two issues. First we add an early test for the Tx and Rx
security block ready bits. By doing this we can avoid the need for waits or
loopback in the event that the security block is already flushed out.
Secondly we fix the boolean logic that was testing for the Tx OR Rx ready
bits being set and change it so that we only exit if the Tx AND Rx ready
bits are both set.
CC: stable <stable@vger.kernel.org>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@oracle.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 38d8cf75e9ad..7b23fb0c2d07 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -158,7 +158,16 @@ static void ixgbe_ipsec_stop_data(struct ixgbe_adapter *adapter)
reg |= IXGBE_SECRXCTRL_RX_DIS;
IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, reg);
- IXGBE_WRITE_FLUSH(hw);
+ /* If both Tx and Rx are ready there are no packets
+ * that we need to flush so the loopback configuration
+ * below is not necessary.
+ */
+ t_rdy = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT) &
+ IXGBE_SECTXSTAT_SECTX_RDY;
+ r_rdy = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT) &
+ IXGBE_SECRXSTAT_SECRX_RDY;
+ if (t_rdy && r_rdy)
+ return;
/* If the tx fifo doesn't have link, but still has data,
* we can't clear the tx sec block. Set the MAC loopback
@@ -185,7 +194,7 @@ static void ixgbe_ipsec_stop_data(struct ixgbe_adapter *adapter)
IXGBE_SECTXSTAT_SECTX_RDY;
r_rdy = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT) &
IXGBE_SECRXSTAT_SECRX_RDY;
- } while (!t_rdy && !r_rdy && limit--);
+ } while (!(t_rdy && r_rdy) && limit--);
/* undo loopback if we played with it earlier */
if (!link) {
--
2.17.1
^ permalink raw reply related
* [net 5/5] ixgbe: Fix bit definitions and add support for testing for ipsec support
From: Jeff Kirsher @ 2018-06-11 16:16 UTC (permalink / raw)
To: davem
Cc: Alexander Duyck, netdev, nhorman, sassmann, jogreene, stable,
Jeff Kirsher
In-Reply-To: <20180611161630.21338-1-jeffrey.t.kirsher@intel.com>
From: Alexander Duyck <alexander.h.duyck@intel.com>
This patch addresses two issues. First it adds the correct bit definitions
for the SECTXSTAT and SECRXSTAT registers. Then it makes use of those
definitions to test for if IPsec has been disabled on the part and if so we
do not enable it.
CC: stable <stable@vger.kernel.org>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Reported-by: Andre Tomt <andre@tomt.net>
Acked-by: Shannon Nelson <shannon.nelson@oracle.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 14 +++++++++++++-
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 6 ++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 7b23fb0c2d07..c116f459945d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -975,10 +975,22 @@ void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
**/
void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter)
{
+ struct ixgbe_hw *hw = &adapter->hw;
struct ixgbe_ipsec *ipsec;
+ u32 t_dis, r_dis;
size_t size;
- if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+ if (hw->mac.type == ixgbe_mac_82598EB)
+ return;
+
+ /* If there is no support for either Tx or Rx offload
+ * we should not be advertising support for IPsec.
+ */
+ t_dis = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT) &
+ IXGBE_SECTXSTAT_SECTX_OFF_DIS;
+ r_dis = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT) &
+ IXGBE_SECRXSTAT_SECRX_OFF_DIS;
+ if (t_dis || r_dis)
return;
ipsec = kzalloc(sizeof(*ipsec), GFP_KERNEL);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index e8ed37749ab1..44cfb2021145 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -599,13 +599,15 @@ struct ixgbe_nvm_version {
#define IXGBE_SECTXCTRL_STORE_FORWARD 0x00000004
#define IXGBE_SECTXSTAT_SECTX_RDY 0x00000001
-#define IXGBE_SECTXSTAT_ECC_TXERR 0x00000002
+#define IXGBE_SECTXSTAT_SECTX_OFF_DIS 0x00000002
+#define IXGBE_SECTXSTAT_ECC_TXERR 0x00000004
#define IXGBE_SECRXCTRL_SECRX_DIS 0x00000001
#define IXGBE_SECRXCTRL_RX_DIS 0x00000002
#define IXGBE_SECRXSTAT_SECRX_RDY 0x00000001
-#define IXGBE_SECRXSTAT_ECC_RXERR 0x00000002
+#define IXGBE_SECRXSTAT_SECRX_OFF_DIS 0x00000002
+#define IXGBE_SECRXSTAT_ECC_RXERR 0x00000004
/* LinkSec (MacSec) Registers */
#define IXGBE_LSECTXCAP 0x08A00
--
2.17.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox