From: Florian Fainelli <f.fainelli@gmail.com>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: NetDev <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>,
John Linville <linville@tuxdriver.com>,
Jamal Hadi Salim <jhs@mojatatu.com>
Subject: Re: [PATCH net-next v5 11/13] net: dsa: add Broadcom SF2 switch driver
Date: Tue, 09 Sep 2014 20:33:17 -0700 [thread overview]
Message-ID: <540FC67D.4070906@gmail.com> (raw)
In-Reply-To: <540FB4AC.3060705@gmail.com>
On 09/09/14 19:17, Alexander Duyck wrote:
[snip]
>>>
>>>> +static char *bcm_sf2_sw_probe(struct mii_bus *bus, int sw_addr)
>>>> +{
>>>> + return "Broadcom Starfighter 2";
>>>> +}
>>>> +
>>> I hadn't noticed before but with this driver it seems like you could
>>> potentially load on any DSA enabled device could you not? It seems
>>> like this would be problematic since you could end up registering
>>> before another DSA driver and prevent it from being able to load since
>>> you always return success. Isn't there any test you could run to
>>> determine if the switch is actually there or not?
>> Unfortunately the current DSA device/driver model is kind of messed up
>> for that, which is something I plan on fixing, although it would take a
>> little bit more time. The way it works currently is:
>>
>> - you register a DSA platform device, feed it with Device Tree or
>> C-struct configuration data
>> - you register a switch driver
>> - the DSA platform code will eventually iterate over all switch devices,
>> call into their probe function and based on a non-NULL return, accept to
>> register this switch device
>> - the probe function only accepts MDIO connected switches, anything else
>> has to find another way to tell that it is there
>>
>> so all of this works okay until you have a switch which is memory-mapped
>> into the CPU address space and which is not on the MDIO bus.
>>
>> A short term solution could be to change the probe argument to be more
>> generic and pass a void *bus pointer or something allowing us to do a
>> tad more things, including verifying a register to see if the switch is
>> there.
>
> I would probably just rewrite the call to accept dsa_chip_data instead
> of passing it the mii_bus and sw_addr. Then you can just access data
> like the of_node directly. I'm also thinking it might make more sense
> to make the mii_bus pointer in the dsa_chip_data a bit more type
> agnostic by simply treating it as a parent device. It seems like most
> of the code is already there in dsa via the dev_find_class check that is
> checking for "mdio_bus".
Yes, I like that.
>
>> The way I would like to fix this model though is to allow switch drivers to:
>>
>> - specify their own configuration data, since for instance, external
>> switches usually have a pretty fixed set of configuration options:
>> number of ports, fixed CPU port, while keeping platform-driven
>> configuration data as well
>>
>> - be backed by their host interface device/driver, e.g: allow a SPI,
>> PHY, PCI(e), USB drivers to register a switch driver, such that there
>> really is a struct device pointer we can refer to for various operations
>> (DMA, PM...)
>
> This is the kind of situation I am looking at. In my case I have a PCIe
> interface with one of the BARs providing access to switch registers. As
> such I would want to be able to provide a PCI device and sort out the
> eligibility to run the driver by checking for the PCI vendor and device ID.
I see, bcm_sf2 is kind of similar here, thanks to Device Tree we can do
a lot of things without being backed by an actual struct device, but
there are other situations where this is not desirable, like yours. In
my case a platform_device/driver would be more appropriate anyway.
>
>> I will cook some patches that do that in the next few days.
>> --
>> Florian
>
> I'll keep an eye open for them. I might start submitting a few patches
> myself as I should be pushing my driver in the next week or two.
Great! I will also keep an eye on it too, I got some patches I would
like to send that add suspend/resume support, Wake-on-LAN and EEE to
DSA/bcm_sf2; but we should probably get the device/driver model right first.
Those are pretty trivial patches anyway that just add some layering
around the DSA and the DSA switch drivers.
NB: I have not yet addressed your suggestion of replacing tag_protocol
with an enum, feel free to send that first.
--
Florian
next prev parent reply other threads:[~2014-09-10 3:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1409184267-1696-1-git-send-email-f.fainelli@gmail.com>
[not found] ` <20140827.181229.2168894985069137270.davem@davemloft.net>
2014-08-28 1:30 ` [PATCH net-next v5 00/13] dsa: Broadcom Starfighter 2 switch support David Miller
2014-08-28 2:51 ` Florian Fainelli
[not found] ` <1409184267-1696-12-git-send-email-f.fainelli@gmail.com>
[not found] ` <CAKgT0UciNUu_AsSmxx62S26Ywbzo4hPZEu00fSsPmXpHMoqPSA@mail.gmail.com>
[not found] ` <540F58E5.7070009@gmail.com>
2014-09-10 2:17 ` [PATCH net-next v5 11/13] net: dsa: add Broadcom SF2 switch driver Alexander Duyck
2014-09-10 3:33 ` Florian Fainelli [this message]
2014-08-28 0:04 [PATCH net-next v5 00/13] dsa: Broadcom Starfighter 2 switch support Florian Fainelli
2014-08-28 0:04 ` [PATCH net-next v5 11/13] net: dsa: add Broadcom SF2 switch driver Florian Fainelli
2014-09-09 19:37 ` Alexander Duyck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=540FC67D.4070906@gmail.com \
--to=f.fainelli@gmail.com \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).