need advice on driver's design

Hello,

I'm about to write a software implementation of MDIO interface, it will be based on two GPIO pins, one is for clock and the other is for data. The utlimate purpose will be to have a control interface between CPU and Ethernet switch.

I see two ways:

1) implement simple functions, say 'mdio_read' and 'mdio_write', in a driver and export them. Write a character driver with 'ioctl' support and provide read/write ioctls for the user level. Applications will then use these I/O controls to set up VLAN functionality, configure ports and so on.

This approach is quite simple, but I'm afraid the performance might be too bad (each user's open/close/read/write is a context switching and expensive)

2) implement 'mdio_read' and 'mdio_write' in the driver and export them. Also implement all the necessary functions (VLAN, IGMP and so on) in the kernel and expose some configuration interface to the user, for example /proc. This will also require mutexes, I beleive. This way things will work probably faster, but harder to debug.

Am I missing something else? What would you say? Thanks.

--
Mark
Reply to
Mark
Loading thread data ...

Hi,

Would drivers/net/phy/mdio-gpio.c be useful? It's a "Generic driver for MDIO bus emulation using GPIO". You can see it at

formatting link

If you're writing the driver from scratch, I'd go with option one as it's simpler and I've found that "first make it work, then make it faster" holds true even for high speed programs.

I've also found that configuration is not usually time sensitive as it is done while the system is booting. I'm not familiar with the MDIO protocol. Will you be configuring at any other time?

Regards, Mike Lewis

Reply to
MikeL

Mark schrieb:

Both /proc and ioctl() are not recommended for new designs. New drivers should have their configuration options in /sys instead of /proc (and respect all the policies of /sys) and do their data exchange preferably via a netlink socket instead of ioctl().

Kind regards

Jan

Reply to
Jan Kandziora

Might be useful, I guess, though it isn't in the kernel 2.6.20 ported for my board.

This GPIO based interface is used at *any* time, for example IGMP snooping application will be using read/write operations very extensively, hence my concern about the performance. But surely, I will first make it work, optimizations will come later.

--
Mark
Reply to
Mark

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.