Skip to content

Commit

Permalink
dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings
Browse files Browse the repository at this point in the history
With multiple APP entries per selector and protocol drivers
or stacks may want to pick a specific value or stripe traffic
across many priorities. Also if an APP entry in use is
deleted the stack/driver may want to choose from the existing
APP entries.

To facilitate this and avoid having duplicate code to walk
the APP ring provide a routine dcb_ieee_getapp_mask() to
return a u8 bitmask of all priorities set for the specified
selector and protocol. This routine and bitmask is a helper
for DCB kernel users.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
John Fastabend authored and davem330 committed Jun 21, 2011
1 parent f9ae7e4 commit a364c8c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/dcbnl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ u8 dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(struct net_device *, struct dcb_app *);
int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
u8 dcb_ieee_getapp_mask(struct net_device *, struct dcb_app *);

int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);

Expand Down
26 changes: 26 additions & 0 deletions net/dcb/dcbnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,32 @@ u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
}
EXPORT_SYMBOL(dcb_setapp);

/**
* dcb_ieee_getapp_mask - retrieve the IEEE DCB application priority
*
* Helper routine which on success returns a non-zero 802.1Qaz user
* priority bitmap otherwise returns 0 to indicate the dcb_app was
* not found in APP list.
*/
u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
{
struct dcb_app_type *itr;
u8 prio = 0;

spin_lock(&dcb_lock);
list_for_each_entry(itr, &dcb_app_list, list) {
if (itr->app.selector == app->selector &&
itr->app.protocol == app->protocol &&
(strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
prio |= 1 << itr->app.priority;
}
}
spin_unlock(&dcb_lock);

return prio;
}
EXPORT_SYMBOL(dcb_ieee_getapp_mask);

/**
* dcb_ieee_setapp - add IEEE dcb application data to app list
*
Expand Down

0 comments on commit a364c8c

Please sign in to comment.