Skip to contentSkip to conversation

Add APNE PCMCIA 100 Mbit support

PATCH Superseded Michael Schmitz 3 participants 16 messages Nov 14, 2021 – Nov 18, 2021

Subsystems (4)

v11 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v11 cover Add APNE PCMCIA 100 Mbit support

The first patch enables the use of core PCMCIA code to parse config table entries in Amiga drivers. The remaining two patches add 16 bit IO support to the m68k low-level IO access code, and add code to the APNE driver to autoprobe for 16 bit IO on cards that support it (the 100 Mbit cards). The core PCMCIA config table parser is utilized for this (may be built as a module; must be selected manually for build in order to enable autoprobe).

Tested by Alex on a 100 Mbit card. Not yet tested on 10 Mbit cards - if any of those also have the 16 bit IO feature set in their config table, this patch series would break on those cards.

Note that only patch 3 has been sent to netdev. Please CC linux-m68k when providing comments.

v11 addresses review comments by Geert.

Cheers,

Michael

#1 lore raw

PATCH v11 1/3 m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Add the interface definition for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c. Include necessary cftable definitions from cistpl.h, remove locally duplicate definitions from amipcmcia.h.

--

Changes from v10:

Geert Uytterhoeven:
- include <pcmcia/ds.h> instead of explict pcmcia_parse_tuple() prototype declaration

Changes from v9:

Geert Uytterhoeven:
- declare declare pcmcia_parse_tuple() unconditionally

Changes from v8:

Geert Uytterhoeven:

- just include pcmcia/cistpl.h; declare pcmcia_parse_tuple() only if core PCMCIA code is included

Changes from v7:

- add interface definitions only, move actual code to apne.c

---
 arch/m68k/include/asm/amipcmcia.h | 45 ++-----------------------------
 1 file changed, 2 insertions(+), 43 deletions(-)
arch/m68k/include/asm/amipcmcia.h +2 -43
index 6f1ec1887d82..fbc80b1d853e 100644
@@ -13,6 +13,8 @@
 #ifndef __AMIGA_PCMCIA_H__
 #define __AMIGA_PCMCIA_H__
 
+#include <pcmcia/cistpl.h>
+#include <pcmcia/ds.h>
 #include <asm/amigayle.h>
 
 /* prototypes */
@@ -64,47 +66,4 @@ static inline void pcmcia_disable_irq(void)
 #define PCMCIA_SPEED_250NS	250
 #define PCMCIA_SPEED_720NS	720
 
-/* PCMCIA Tuple codes */
-
-#define CISTPL_NULL		0x00
-#define CISTPL_DEVICE		0x01
-#define CISTPL_LONGLINK_CB	0x02
-#define CISTPL_CONFIG_CB	0x04
-#define CISTPL_CFTABLE_ENTRY_CB	0x05
-#define CISTPL_LONGLINK_MFC	0x06
-#define CISTPL_BAR		0x07
-#define CISTPL_CHECKSUM		0x10
-#define CISTPL_LONGLINK_A	0x11
-#define CISTPL_LONGLINK_C	0x12
-#define CISTPL_LINKTARGET	0x13
-#define CISTPL_NO_LINK		0x14
-#define CISTPL_VERS_1		0x15
-#define CISTPL_ALTSTR		0x16
-#define CISTPL_DEVICE_A		0x17
-#define CISTPL_JEDEC_C		0x18
-#define CISTPL_JEDEC_A		0x19
-#define CISTPL_CONFIG		0x1a
-#define CISTPL_CFTABLE_ENTRY	0x1b
-#define CISTPL_DEVICE_OC	0x1c
-#define CISTPL_DEVICE_OA	0x1d
-#define CISTPL_DEVICE_GEO	0x1e
-#define CISTPL_DEVICE_GEO_A	0x1f
-#define CISTPL_MANFID		0x20
-#define CISTPL_FUNCID		0x21
-#define CISTPL_FUNCE		0x22
-#define CISTPL_SWIL		0x23
-#define CISTPL_END		0xff
-
-/* FUNCID */
-
-#define CISTPL_FUNCID_MULTI	0x00
-#define CISTPL_FUNCID_MEMORY	0x01
-#define CISTPL_FUNCID_SERIAL	0x02
-#define CISTPL_FUNCID_PARALLEL	0x03
-#define CISTPL_FUNCID_FIXED	0x04
-#define CISTPL_FUNCID_VIDEO	0x05
-#define CISTPL_FUNCID_NETWORK	0x06
-#define CISTPL_FUNCID_AIMS	0x07
-#define CISTPL_FUNCID_SCSI	0x08
-
 #endif
Signature · 1 line
2.17.1
maintainer Reviewed-by on v11 1/3
#2 lore raw

Re: [PATCH v11 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Quoted 6 lines · Michael Schmitz

Add the interface definition for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c. Include necessary cftable definitions from cistpl.h, remove locally duplicate definitions from amipcmcia.h.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw

Re: [PATCH v11 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Thanks Geert,

Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Michael Schmitz

Add the interface definition for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c. Include necessary cftable definitions from cistpl.h, remove locally duplicate definitions from amipcmcia.h.

I may have to give this another spin, in order to address a review comment by Denis about making the apne.c 16 bit IO autoprobe module parameter ('100mbit') a sysfs parameter.

I suggest to move that parameter to arch/m68k/amiga/pcmcia.c to ensure it's always visible, and rename it to better reflect its actual function (pcmcia_16bit comes to mind). apne.c would then use that parameter to autoprobe 16 bit IO support, or set isa_type according to the parameter.

Would that satisfy your concerns, Denis?

Cheers,

Michael

Quoted 12 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#4 lore raw

Re: [PATCH v11 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Hi Michael,

Quoted 15 lines · Michael Schmitz
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Michael Schmitz

Add the interface definition for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c. Include necessary cftable definitions from cistpl.h, remove locally duplicate definitions from amipcmcia.h.

I may have to give this another spin, in order to address a review comment by Denis about making the apne.c 16 bit IO autoprobe module parameter ('100mbit') a sysfs parameter.

Quoted 6 lines

I suggest to move that parameter to arch/m68k/amiga/pcmcia.c to ensure it's always visible, and rename it to better reflect its actual function (pcmcia_16bit comes to mind). apne.c would then use that parameter to autoprobe 16 bit IO support, or set isa_type according to the parameter.

Would that satisfy your concerns, Denis?

What's the point of the sysfs parameter, given the driver cannot be unbound and rebound, as it does not use the driver model yet? The only thing you can (try to) do is unload and reload the module, at which point you can pass the module parameter again?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#5 lore raw

Re: [PATCH v11 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Hi Geert,

Quoted 23 lines · Geert Uytterhoeven

Hi Michael,

Quoted 20 lines · Michael Schmitz
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Michael Schmitz

Add the interface definition for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c. Include necessary cftable definitions from cistpl.h, remove locally duplicate definitions from amipcmcia.h.

I may have to give this another spin, in order to address a review comment by Denis about making the apne.c 16 bit IO autoprobe module parameter ('100mbit') a sysfs parameter.

I suggest to move that parameter to arch/m68k/amiga/pcmcia.c to ensure it's always visible, and rename it to better reflect its actual function (pcmcia_16bit comes to mind). apne.c would then use that parameter to autoprobe 16 bit IO support, or set isa_type according to the parameter.

Quoted 4 lines
Quoted 1 line

Would that satisfy your concerns, Denis?

What's the point of the sysfs parameter, given the driver cannot be unbound and rebound, as it does not use the driver model yet?

Pre-setting the desired IO type before loading the module - though actual setting of isa_type still has to wait until module load (or driver probe). I'd have to write a callback that validates user input if we want to set isa_type directly in pcmcia.c ...

Quoted 2 lines

The only thing you can (try to) do is unload and reload the module, at which point you can pass the module parameter again?

I take that as 'don't do that', then ... ?

Cheers,

Michael

Quoted 12 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#6 lore raw

Re: [PATCH v11 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Hi Michael,

Quoted 24 lines · Michael Schmitz
Quoted 23 lines · Geert Uytterhoeven
Quoted 21 lines · Michael Schmitz
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Michael Schmitz

Add the interface definition for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c. Include necessary cftable definitions from cistpl.h, remove locally duplicate definitions from amipcmcia.h.

I may have to give this another spin, in order to address a review comment by Denis about making the apne.c 16 bit IO autoprobe module parameter ('100mbit') a sysfs parameter.

I suggest to move that parameter to arch/m68k/amiga/pcmcia.c to ensure it's always visible, and rename it to better reflect its actual function (pcmcia_16bit comes to mind). apne.c would then use that parameter to autoprobe 16 bit IO support, or set isa_type according to the parameter.

Would that satisfy your concerns, Denis?

Quoted 7 lines
Quoted 2 lines

What's the point of the sysfs parameter, given the driver cannot be unbound and rebound, as it does not use the driver model yet?

Pre-setting the desired IO type before loading the module - though actual setting of isa_type still has to wait until module load (or driver probe). I'd have to write a callback that validates user input if we want to set isa_type directly in pcmcia.c ...

IMHO the sysfs parameter would only make sense if all of the 8/16-bit handling (and the special reset) is done in arch/m68k/amiga/pcmcia.c, so it can be shared for multiple cards.

Quoted 4 lines
Quoted 2 lines

The only thing you can (try to) do is unload and reload the module, at which point you can pass the module parameter again?

I take that as 'don't do that', then ... ?

I meant you can do the above without the sysfs parameter.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#7 lore raw

Re: [PATCH v11 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h

Hi Geert,

Quoted 10 lines · Geert Uytterhoeven
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

I suggest to move that parameter to arch/m68k/amiga/pcmcia.c to ensure it's always visible, and rename it to better reflect its actual function (pcmcia_16bit comes to mind). apne.c would then use that parameter to autoprobe 16 bit IO support, or set isa_type according to the parameter.

Would that satisfy your concerns, Denis?

What's the point of the sysfs parameter, given the driver cannot be unbound and rebound, as it does not use the driver model yet?

Quoted 8 lines
Quoted 4 lines

Pre-setting the desired IO type before loading the module - though actual setting of isa_type still has to wait until module load (or driver probe). I'd have to write a callback that validates user input if we want to set isa_type directly in pcmcia.c ...

IMHO the sysfs parameter would only make sense if all of the 8/16-bit handling (and the special reset) is done in arch/m68k/amiga/pcmcia.c, so it can be shared for multiple cards.

Do we even have any other cards/drivers that work with the Amiga PCMCIA port?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The only thing you can (try to) do is unload and reload the module, at which point you can pass the module parameter again?

I take that as 'don't do that', then ... ?

I meant you can do the above without the sysfs parameter.

I wasn't overly clear there - what I meant is, I take your comment to mean 'don't bother adding a sysfs parameter that does not add any extra functionality'.

The module parameter will appear in sysfs and can be used to read out the 16 bit IO state anyway.

Cheers,

Michael

Quoted 11 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#8 lore raw

PATCH v11 2/3 m68k: io_mm.h - add APNE 100 MBit support

In reply to Michael Schmitz

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG16 dynamically switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

--
Changes from v4:

Geert Uytterhoeven:
- drop CONFIG_APNE100MBIT ifdefs

Changes from v3:

Finn Thain:
- revert isa_inb() define reordering
- omit redundant #ifdef around ISA_TYPE_AG16 case labels

Changes from v1:

Andreas Schwab:
- remove redundant fallthrough annotations

Changes from RFC:

Geert Uytterhoeven:
- rename ISA_TYPE_AG100 to ISA_TYPE_AG16 (16 bit cards)
- move ISA_TYPE_AG16 case inside #ifdef CONFIG_AMIGA_PCMCIA
- change #if defined(CONFIG_APNE_100MBIT) to #ifdef
- fix parentheses in isa_inb() define
- omit comment about compiler optimization

- add ISA_TYPE_AG16 case to isa_delay()

---
 arch/m68k/include/asm/io_mm.h | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
arch/m68k/include/asm/io_mm.h +11 -5
index d41fa488453b..abb9e5ddb012 100644
@@ -61,12 +61,10 @@
 #define AG_ISA_IO_B(ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )
 #define AG_ISA_IO_W(ioaddr) ( GAYLE_IO+(ioaddr) )
 
-#ifndef MULTI_ISA
-#define MULTI_ISA 0
-#else
+#ifdef MULTI_ISA
 #undef MULTI_ISA
-#define MULTI_ISA 1
 #endif
+#define MULTI_ISA 1	/* Need MULTI_ISA for 16 bit PCMCIA card support ! */
 #endif /* AMIGA_PCMCIA */
 
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -97,6 +95,8 @@
 #define ISA_TYPE_Q40  (1)
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
+#define ISA_TYPE_AG16 (4)	/* for 100 MBit APNE card */
+
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -132,6 +132,7 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+    case ISA_TYPE_AG16:
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -148,6 +149,7 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+    case ISA_TYPE_AG16:
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -161,6 +163,7 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
   switch(ISA_TYPE)
     {
 #ifdef CONFIG_AMIGA_PCMCIA
+    case ISA_TYPE_AG16:
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
     default: return 0; /* avoid warnings, just in case */
@@ -174,6 +177,7 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+    case ISA_TYPE_AG16:
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -190,6 +194,7 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+    case ISA_TYPE_AG16:
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -200,7 +205,7 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG16) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port)))
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
@@ -254,6 +259,7 @@ static inline void isa_delay(void)
     case ISA_TYPE_Q40: isa_outb(0,0x80); break;
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+    case ISA_TYPE_AG16: break;
     case ISA_TYPE_AG: break;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
Signature · 1 line
2.17.1
#9 lore raw

PATCH v11 3/3 net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing isa_type at runtime. The user must select PCCARD and PCMCIA in the kernel config to make the necessary support modules available

Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.

An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

--

Changes from v9:

- avoid pcmcia_is_16bit() forward declaration

Randy Dunlap:
- do not select PCCARD and PCMCIA options when selecting APNE

Changes from v8:

Geert Uytterhoeven:
- cistpl.h definitions now provided through amipcmcia.h
- really change module parameter to (signed) int

Changes from v7:

- move 'select' for PCCARD and PCMCIA to 8390 Kconfig, so Amiga pcmcia.c may remain built-in while core PCMCIA code can be built as modules if APNE driver is a module.
- move 16 bit mode autoprobe code from amiga/pcmcia.c to this driver, to allow the core PCMCIA code we depend on to be built as modules.
- change module parameter type from bool to int to allow for tri-state semantics (autoprobe, 8 bit, 16 bit).

Changes from v6:

- use 16 bit mode autoprobe based on PCMCIA config table data

Changes from v5:

- move autoprobe code to new patch in this series

Geert Uytterhoeven:
- reword Kconfig help text

Finn Thain:
- style fixes, use msec_to_jiffies in timeout calc

Alex Kazik:
- revert module parameter permission change

Changes from v4:

Geert Uytterhoeven:
- remove APNE100MBIT config option, always include 16 bit support
- change module parameter permissions
- try autoprobing for 16 bit mode early on in device probe

Changes from v3:

- change module parameter name to match Kconfig help

Finn Thain:
- fix coding style in new card reset code block
- allow reset of isa_type by module parameter

Changes from v1:

- fix module parameter name in Kconfig help text

Alex Kazik:
- change module parameter type to bool, fix module parameter permission

Changes from RFC:

Geert Uytterhoeven:
- change APNE_100MBIT to depend on APNE
- change '---help---' to 'help' (former no longer supported)
- fix whitespace errors
- fix module_param_named() arg count
- protect all added code by #ifdef CONFIG_APNE_100MBIT

---
 drivers/net/ethernet/8390/Kconfig |  8 ++++
 drivers/net/ethernet/8390/apne.c  | 67 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
drivers/net/ethernet/8390/Kconfig +8 -0
index a4130e643342..c4f519a385f3 100644
@@ -144,6 +144,14 @@ config APNE
 	  To compile this driver as a module, choose M here: the module
 	  will be called apne.
 
+	  The driver also supports 10/100Mbit cards (e.g. Netgear FA411,
+	  CNet Singlepoint). To activate 100 Mbit support, use the kernel
+	  option apne.100mbit=1 (builtin) at boot time, or the apne.100mbit
+	  module parameter. The driver can attempt to autoprobe 100 Mbit
+	  mode if the PCCARD and PCMCIA kernel configuration options are
+	  selected, so this option may not be necessary. Use apne.100mbit=0
+	  should autoprobe mis-detect a 100 Mbit card.
+
 config PCMCIA_PCNET
 	tristate "NE2000 compatible PCMCIA support"
 	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +67 -0

91 lines not on this page · raw message

Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH net v11 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Michael,

Quoted 16 lines · Michael Schmitz

Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing isa_type at runtime. The user must select PCCARD and PCMCIA in the kernel config to make the necessary support modules available

Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.

An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.

Quoted 8 lines

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

Thanks for your patch!

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 126

Quoted 11 lines
drivers/net/ethernet/8390/apne.c +5 -0
@@ -119,6 +119,48 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+static int apne_100_mbit = -1;
+module_param_named(100_mbit, apne_100_mbit, int, 0444);
+MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");
+
+#if IS_ENABLED(CONFIG_PCMCIA)

What if CONFIG_PCMIA=m, and CONFIG_APNE=y?

Quoted 14 lines
drivers/net/ethernet/8390/apne.c +14 -0
+static int pcmcia_is_16bit(void)
+{
+       u_char cftuple[258];
+       int cftuple_len;
+       tuple_t cftable_tuple;
+       cistpl_cftable_entry_t cftable_entry;
+
+       cftuple_len = pcmcia_copy_tuple(CISTPL_CFTABLE_ENTRY, cftuple, 256);
+       if (cftuple_len < 3)
+               return 0;
+#ifdef DEBUG
+       else
+               print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8,
+                              sizeof(char), cftuple, cftuple_len, false);

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 150

Quoted 10 lines
drivers/net/ethernet/8390/apne.c +10 -0
+#endif
+
+       /* build tuple_t struct and call pcmcia_parse_tuple */
+       cftable_tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       cftable_tuple.TupleCode = CISTPL_CFTABLE_ENTRY;
+       cftable_tuple.TupleData = &cftuple[2];
+       cftable_tuple.TupleDataLen = cftuple_len - 2;
+       cftable_tuple.TupleDataMax = cftuple_len - 2;
+
+       if (pcmcia_parse_tuple(&cftable_tuple, (cisparse_t *)&cftable_entry))

Can't you avoid the cast, by changing the type of cftable_entry? Perhaps you don't want to do that, to avoid abusing it below, but perhaps you can use container_of() instead of the cast?

Quoted 31 lines
drivers/net/ethernet/8390/apne.c +20 -0
+               return 0;
+
+#ifdef DEBUG
+       pr_info("IO flags: %x\n", cftable_entry.io.flags);
+#endif
+
+       if (cftable_entry.io.flags & CISTPL_IO_16BIT)
+               return 1;
+
+       return 0;
+}
+#endif
+
 static struct net_device * __init apne_probe(void)
 {
        struct net_device *dev;
@@ -140,6 +182,13 @@ static struct net_device * __init apne_probe(void)
 
        pr_info("Looking for PCMCIA ethernet card : ");
 
+       if (apne_100_mbit == 1)
+               isa_type = ISA_TYPE_AG16;
+       else if (apne_100_mbit == 0)
+               isa_type = ISA_TYPE_AG;
+       else
+               pr_cont(" (autoprobing 16 bit mode) ");
+
        /* check if a card is inserted */
        if (!(PCMCIA_INSERTED)) {
                pr_cont("NO PCMCIA card inserted\n");

drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 224

Quoted 9 lines
drivers/net/ethernet/8390/apne.c +6 -0
@@ -167,6 +216,14 @@ static struct net_device * __init apne_probe(void)
 
        pr_cont("ethernet PCMCIA card inserted\n");
 
+#if IS_ENABLED(CONFIG_PCMCIA)
+       if (apne_100_mbit < 0 && pcmcia_is_16bit()) {
+               pr_info("16-bit PCMCIA card detected!\n");
+               isa_type = ISA_TYPE_AG16;
+               apne_100_mbit = 1;
+       }

I think you should reset apne_100_mbit to zero if apne_100_mbit < 0 && !pcmcia_is_16bit(), so rmmod + switching card + modprobe has a chance to work.

drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 229

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2 -0
+#endif
+
        if (!init_pcmcia()) {
                /* XXX: shouldn't we re-enable irq here? */
                free_netdev(dev);

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#11 lore raw

Re: [PATCH net v11 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Geert,

thanks for your review!

Quoted 36 lines · Geert Uytterhoeven

Hi Michael,

Quoted 16 lines · Michael Schmitz

Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing isa_type at runtime. The user must select PCCARD and PCMCIA in the kernel config to make the necessary support modules available

Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.

An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.

Quoted 8 lines

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

Thanks for your patch!

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +0 -0
@@ -119,6 +119,48 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
Quoted 7 lines

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 126

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+static int apne_100_mbit = -1;
+module_param_named(100_mbit, apne_100_mbit, int, 0444);
+MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");
+
+#if IS_ENABLED(CONFIG_PCMCIA)

What if CONFIG_PCMIA=m, and CONFIG_APNE=y?

Fails to build (undefined reference to `pcmcia_parse_tuple').

That's what 'select PCMCIA' was avoiding before, but got vetoed. I can add a dependency on PCMCIA in the APNE Kconfig entry which does force APNE the same as what's selected for PCMCIA, but that means we can't build APNE without PCMCIA anymore. Is there a way to express 'constrain build type if PCMCIA is enabled, else leave choice to user' ??

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/8390/apne.c +18 -0
+static int pcmcia_is_16bit(void)
+{
+       u_char cftuple[258];
+       int cftuple_len;
+       tuple_t cftable_tuple;
+       cistpl_cftable_entry_t cftable_entry;
+
+       cftuple_len = pcmcia_copy_tuple(CISTPL_CFTABLE_ENTRY, cftuple, 256);
+       if (cftuple_len < 3)
+               return 0;
+#ifdef DEBUG
+       else
+               print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8,
+                              sizeof(char), cftuple, cftuple_len, false);
+#endif
+
+       /* build tuple_t struct and call pcmcia_parse_tuple */
+       cftable_tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
Quoted 8 lines

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 150

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +6 -0
+       cftable_tuple.TupleCode = CISTPL_CFTABLE_ENTRY;
+       cftable_tuple.TupleData = &cftuple[2];
+       cftable_tuple.TupleDataLen = cftuple_len - 2;
+       cftable_tuple.TupleDataMax = cftuple_len - 2;
+
+       if (pcmcia_parse_tuple(&cftable_tuple, (cisparse_t *)&cftable_entry))

Can't you avoid the cast, by changing the type of cftable_entry?

Sure, could declare cisparse_t cfparse above, and prepend cfparse. at all uses of cftable_entry below.

Quoted 2 lines

Perhaps you don't want to do that, to avoid abusing it below, but perhaps you can use container_of() instead of the cast?

Wasn't sure container_of() works with unions, but that seems to avoid the cast OK as well.

Quoted 35 lines
Quoted 35 lines
drivers/net/ethernet/8390/apne.c +20 -0
+               return 0;
+
+#ifdef DEBUG
+       pr_info("IO flags: %x\n", cftable_entry.io.flags);
+#endif
+
+       if (cftable_entry.io.flags & CISTPL_IO_16BIT)
+               return 1;
+
+       return 0;
+}
+#endif
+
 static struct net_device * __init apne_probe(void)
 {
        struct net_device *dev;
@@ -140,6 +182,13 @@ static struct net_device * __init apne_probe(void)
 
        pr_info("Looking for PCMCIA ethernet card : ");
 
+       if (apne_100_mbit == 1)
+               isa_type = ISA_TYPE_AG16;
+       else if (apne_100_mbit == 0)
+               isa_type = ISA_TYPE_AG;
+       else
+               pr_cont(" (autoprobing 16 bit mode) ");
+
        /* check if a card is inserted */
        if (!(PCMCIA_INSERTED)) {
                pr_cont("NO PCMCIA card inserted\n");
@@ -167,6 +216,14 @@ static struct net_device * __init apne_probe(void)
 
        pr_cont("ethernet PCMCIA card inserted\n");
 
Quoted 10 lines

drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 224

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +6 -0
+#if IS_ENABLED(CONFIG_PCMCIA)
+       if (apne_100_mbit < 0 && pcmcia_is_16bit()) {
+               pr_info("16-bit PCMCIA card detected!\n");
+               isa_type = ISA_TYPE_AG16;
+               apne_100_mbit = 1;
+       }

I think you should reset apne_100_mbit to zero if apne_100_mbit < 0 && !pcmcia_is_16bit(), so rmmod + switching card + modprobe has a chance to work.

Good catch - though when switching to another card using this same driver, the module parameter can be used again to select IO mode or force autoprobe.

I'll wait for your response about the sysfs parameter issue before sending out v12.

Cheers,

Michael

Quoted 19 lines

drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 229

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +2 -0
+#endif
+
        if (!init_pcmcia()) {
                /* XXX: shouldn't we re-enable irq here? */
                free_netdev(dev);

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#12 lore raw

Re: [PATCH net v11 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Michael,

Quoted 41 lines · Michael Schmitz
Quoted 32 lines · Geert Uytterhoeven
Quoted 31 lines · Michael Schmitz

Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing isa_type at runtime. The user must select PCCARD and PCMCIA in the kernel config to make the necessary support modules available

Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.

An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

drivers/net/ethernet/8390/apne.c +0 -0
@@ -119,6 +119,48 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
Quoted 7 lines

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 126

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+static int apne_100_mbit = -1;
+module_param_named(100_mbit, apne_100_mbit, int, 0444);
+MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");
+
+#if IS_ENABLED(CONFIG_PCMCIA)

What if CONFIG_PCMIA=m, and CONFIG_APNE=y?

Quoted 7 lines

Fails to build (undefined reference to `pcmcia_parse_tuple').

That's what 'select PCMCIA' was avoiding before, but got vetoed. I can add a dependency on PCMCIA in the APNE Kconfig entry which does force APNE the same as what's selected for PCMCIA, but that means we can't build APNE without PCMCIA anymore. Is there a way to express 'constrain build type if PCMCIA is enabled, else leave choice to user' ??

#if IS_REACHABLE(CONFIG_PCMIA)

Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
drivers/net/ethernet/8390/apne.c +7 -0
@@ -140,6 +182,13 @@ static struct net_device * __init apne_probe(void)
 
        pr_info("Looking for PCMCIA ethernet card : ");
 
+       if (apne_100_mbit == 1)
+               isa_type = ISA_TYPE_AG16;
+       else if (apne_100_mbit == 0)
+               isa_type = ISA_TYPE_AG;
+       else
+               pr_cont(" (autoprobing 16 bit mode) ");
+
        /* check if a card is inserted */
        if (!(PCMCIA_INSERTED)) {
                pr_cont("NO PCMCIA card inserted\n");
@@ -167,6 +216,14 @@ static struct net_device * __init apne_probe(void)
 
        pr_cont("ethernet PCMCIA card inserted\n");
 
Quoted 10 lines

drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 224

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +6 -0
+#if IS_ENABLED(CONFIG_PCMCIA)
+       if (apne_100_mbit < 0 && pcmcia_is_16bit()) {
+               pr_info("16-bit PCMCIA card detected!\n");
+               isa_type = ISA_TYPE_AG16;
+               apne_100_mbit = 1;
+       }

I think you should reset apne_100_mbit to zero if apne_100_mbit < 0 && !pcmcia_is_16bit(), so rmmod + switching card + modprobe has a chance to work.

Quoted 3 lines

Good catch - though when switching to another card using this same driver, the module parameter can be used again to select IO mode or force autoprobe.

The autoprobe won't work if the new card is 8-bit.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#13 lore raw

Re: [PATCH net v11 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Geert,

Quoted 16 lines · Geert Uytterhoeven
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/8390/apne.c +0 -0
@@ -119,6 +119,48 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
Quoted 7 lines

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 126

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+static int apne_100_mbit = -1;
+module_param_named(100_mbit, apne_100_mbit, int, 0444);
+MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");
+
+#if IS_ENABLED(CONFIG_PCMCIA)

What if CONFIG_PCMIA=m, and CONFIG_APNE=y?

Fails to build (undefined reference to `pcmcia_parse_tuple').

Quoted 7 lines
Quoted 5 lines

That's what 'select PCMCIA' was avoiding before, but got vetoed. I can add a dependency on PCMCIA in the APNE Kconfig entry which does force APNE the same as what's selected for PCMCIA, but that means we can't build APNE without PCMCIA anymore. Is there a way to express 'constrain build type if PCMCIA is enabled, else leave choice to user' ??

#if IS_REACHABLE(CONFIG_PCMIA)

Thanks, I'll use that then.

Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 15 lines
drivers/net/ethernet/8390/apne.c +7 -0
@@ -140,6 +182,13 @@ static struct net_device * __init apne_probe(void)
 
        pr_info("Looking for PCMCIA ethernet card : ");
 
+       if (apne_100_mbit == 1)
+               isa_type = ISA_TYPE_AG16;
+       else if (apne_100_mbit == 0)
+               isa_type = ISA_TYPE_AG;
+       else
+               pr_cont(" (autoprobing 16 bit mode) ");
+
        /* check if a card is inserted */
        if (!(PCMCIA_INSERTED)) {
                pr_cont("NO PCMCIA card inserted\n");

drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 224

Quoted 9 lines
drivers/net/ethernet/8390/apne.c +6 -0
@@ -167,6 +216,14 @@ static struct net_device * __init apne_probe(void)
 
        pr_cont("ethernet PCMCIA card inserted\n");
 
+#if IS_ENABLED(CONFIG_PCMCIA)
+       if (apne_100_mbit < 0 && pcmcia_is_16bit()) {
+               pr_info("16-bit PCMCIA card detected!\n");
+               isa_type = ISA_TYPE_AG16;
+               apne_100_mbit = 1;
+       }

I think you should reset apne_100_mbit to zero if apne_100_mbit < 0 && !pcmcia_is_16bit(), so rmmod + switching card + modprobe has a chance to work.

Quoted 5 lines
Quoted 3 lines

Good catch - though when switching to another card using this same driver, the module parameter can be used again to select IO mode or force autoprobe.

The autoprobe won't work if the new card is 8-bit.

I see now - adding code to set isa_type to 8 bit if the autoprobe fails, and reset isa_type and apne_100_mbit to defaults in module exit and the probe error return path ...

Cheers,

Michael

Quoted 12 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#14 lore raw

Re: [PATCH net v11 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz
Quoted 2 lines · Michael Schmitz

Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

[]

drivers/net/ethernet/8390/apne.c

Quoted 1 line
drivers/net/ethernet/8390/apne.c +0 -0

[]

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable;

Quoted 1 line
drivers/net/ethernet/8390/apne.c +0 -0
@@ -119,6 +119,48 @@ static u32 apne_msg_enable;

[]

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 141

Quoted 8 lines
drivers/net/ethernet/8390/apne.c +8 -0
+	cftuple_len = pcmcia_copy_tuple(CISTPL_CFTABLE_ENTRY, cftuple, 256);
+	if (cftuple_len < 3)
+		return 0;
+#ifdef DEBUG
+	else
+		print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8,
+			       sizeof(char), cftuple, cftuple_len, false);
+#endif

Why KERN_WARNING and why not use print_hex_dump_debug without the #ifdef

[]

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 128

Quoted 2 lines
drivers/net/ethernet/8390/apne.c +2 -0
+#ifdef DEBUG
+	pr_info("IO flags: %x\n", cftable_entry.io.flags);

pr_debug ?

#15 lore raw

Re: [PATCH net v11 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Joe,

thanks for your review!

Quoted 8 lines · Joe Perches
Quoted 2 lines · Michael Schmitz

Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

[]

drivers/net/ethernet/8390/apne.c

Quoted 1 line
drivers/net/ethernet/8390/apne.c +0 -0

[]

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable;

Quoted 1 line
drivers/net/ethernet/8390/apne.c +0 -0
@@ -119,6 +119,48 @@ static u32 apne_msg_enable;

[]

Quoted 10 lines

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 141

Quoted 8 lines
drivers/net/ethernet/8390/apne.c +8 -0
+	cftuple_len = pcmcia_copy_tuple(CISTPL_CFTABLE_ENTRY, cftuple, 256);
+	if (cftuple_len < 3)
+		return 0;
+#ifdef DEBUG
+	else
+		print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8,
+			       sizeof(char), cftuple, cftuple_len, false);
+#endif

Why KERN_WARNING and why not use print_hex_dump_debug without the #ifdef

No particular reason - head still stuck in the '90 perhaps.

Quoted 5 lines

[]

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 128

Quoted 2 lines
drivers/net/ethernet/8390/apne.c +2 -0
+#ifdef DEBUG
+	pr_info("IO flags: %x\n", cftable_entry.io.flags);

pr_debug ?

Both changed now, thanks!

Regards,

Michael Schmitz

Quoted 1 line