[netdevice] Allocate private data for each network upper-layer driver

Allow network upper-layer drivers (such as LLDP, which attaches to
each network device in order to provide a corresponding LLDP settings
block) to specify a size for private data, which will be allocated as
part of the network device structure (as with the existing private
data allocated for the underlying device driver).

This will allow network upper-layer drivers to be simplified by
omitting memory allocation and freeing code.  If the upper-layer
driver requires a reference counter (e.g. for interface
initialisation), then it may use the network device's existing
reference counter, since this is now the reference counter for the
containing block of memory.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2023-09-13 16:29:59 +01:00
parent eeb7cd56e5
commit ae4e85bde9
13 changed files with 110 additions and 34 deletions

View File

@@ -470,9 +470,10 @@ void vlan_auto ( const void *ll_addr, unsigned int tag ) {
* Create automatic VLAN device
*
* @v trunk Trunk network device
* @v priv Private data
* @ret rc Return status code
*/
static int vlan_probe ( struct net_device *trunk ) {
static int vlan_probe ( struct net_device *trunk, void *priv __unused ) {
int rc;
/* Do nothing unless an automatic VLAN exists */
@@ -498,8 +499,9 @@ static int vlan_probe ( struct net_device *trunk ) {
* Handle trunk network device link state change
*
* @v trunk Trunk network device
* @v priv Private data
*/
static void vlan_notify ( struct net_device *trunk ) {
static void vlan_notify ( struct net_device *trunk, void *priv __unused ) {
struct net_device *netdev;
struct vlan_device *vlan;
@@ -538,8 +540,9 @@ static int vlan_remove_first ( struct net_device *trunk ) {
* Destroy all VLAN devices for a given trunk
*
* @v trunk Trunk network device
* @v priv Private data
*/
static void vlan_remove ( struct net_device *trunk ) {
static void vlan_remove ( struct net_device *trunk, void *priv __unused ) {
/* Remove all VLAN devices attached to this trunk, safe
* against arbitrary net device removal.