Skip to contentSkip to conversation

net_device + pci_dev question

DISCUSSION Mateusz Berezecki 2 participants 5 messages Nov 27, 2005 – Nov 28, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello List!

Having only net_device pointer is it possible to retrieve associated pci_dev pointer basing on this information only?

kind regards,
Mateusz Berezecki

#1 lore raw
Quoted 4 lines · Mateusz Berezecki

Hello List!

Having only net_device pointer is it possible to retrieve associated pci_dev pointer basing on this information only?

what do you need it for?

(and.. what if the nic isn't a pci one?)

#2 lore raw

Hello Arjan,

Quoted 7 lines · On 27th november 2005 (22:25:13) you wrote:
Quoted 4 lines · Mateusz Berezecki

Hello List!

Having only net_device pointer is it possible to retrieve associated pci_dev pointer basing on this information only?

what do you need it for?

for pci_alloc_consistent() which takes pci_dev as a first argument to allocate contiguous memory block for DMA transfers. I just realized when I saw your answer that I might have moved the memory allocation to some routine which is called earlier in time which has access to pci_dev pointer directly, like net_device->init IIRC. But I'm not really sure if that would be correct solution.

Quoted 1 line

(and.. what if the nic isn't a pci one?)

Uh... it's cardbus interface and still uses pci_* stuff without problems. (?) Do I miss something?

kind regards
Mateusz Berezecki

#3 lore raw
Quoted 7 lines · Mateusz Berezecki

Hello Arjan,

Quoted 3 lines · On 27th november 2005 (22:25:13) you wrote:
Quoted 2 lines · Mateusz Berezecki

Hello List!

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Having only net_device pointer is it possible to retrieve associated pci_dev pointer basing on this information only?

what do you need it for?

for pci_alloc_consistent() which takes pci_dev as a first argument to allocate contiguous memory block for DMA transfers. I just realized

oh it's *your own* netdev...

that makes things a lot easier ;)

it's custom to have driver private data per net dev
(see netdev_priv() to get it, alloc_etherdev() takes the size of it as argument). It's custom to make that private data a struct in which you can store the pci device pointer yourself, as well as any other per card data that you need to store

#4 lore raw

Hello Arjan,

Quoted 1 line · On 28th november 2005 (22:03:38) you wrote:

oh it's *your own* netdev...

Yes:-) Sorry for not being precise

Quoted 8 lines

that makes things a lot easier ;)

it's custom to have driver private data per net dev
(see netdev_priv() to get it, alloc_etherdev() takes the size of it as argument). It's custom to make that private data a struct in which you can store the pci device pointer yourself, as well as any other per card data that you need to store

Ok, I will do it like that then. Thank you for the explanation on this issue.

kind regards,
Mateusz Berezecki