bnx2x: patch series
cover bnx2x: patch series
Hi Dave,
This patch series contains several SR-IOV related patches - it allows setting and querying the number of vfs via sysfs, configuring and querying VFs via iproute2 callbacks and properly implements for VFs only the ethtool ops which they can safely perform.
In addition, it also contains several small fixes of rare corner-cases.
Please consider applying this patch-series to 'net-next'.
Thanks,
Yuval Mintz
PATCH 1/9 bnx2x: Prevent NULL pointer dereference in vlan-mac
When setting the vlan mac configuration in the bnx2x driver, there is a registry list (shadow list) which was accessed without a lock.
Under specific stress-testing tests, it was possible to have a NULL pointer dereference as one context would have emptied the list while the other accessed its elements.
This adds a variation on a classical single writer, multiple reader lock in which writers don't wait for the list to be accessible but rather pend their request to be performed once the list is available. This prevents said issue.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 433 ++++++++++++++++++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 18 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 9 +- 3 files changed, 448 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +422 -11
@@ -184,6 +184,7 @@ static inline void bnx2x_exe_queue_reset_pending(struct bnx2x *bp,* (Atomicy is ensured using the exe_queue->lock). */ static inline int bnx2x_exe_queue_step (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *vobj,struct bnx2x_exe_queue_obj *o,unsigned long *ramrod_flags) {
@@ -194,6 +195,13 @@ static inline int bnx2x_exe_queue_step(struct bnx2x *bp,spin_lock_bh (&o->lock); +/* From here on we're under the context of the execution queue lock. +* Whether or not an execution will be made, we can clear the vlan_mac +* head pending execution reference, since accessing it must also be +* done under this lock (there's no chance for race) +*/ + vobj->head_exe = false; +/* * Next step should not be performed until the current is finished, * unless a DRV_CLEAR_ONLY bit is set. In this case we just want to
@@ -443,12 +451,333 @@ static bool bnx2x_put_credit_vlan_mac(struct bnx2x_vlan_mac_obj *o)return true; } +#define BNX2X_VLAN_MAC_H_LOCK_TIMEOUT (5000) +/** +* __bnx2x_vlan_mac_h_write_trylock - try getting the writer lock on vlan mac +* head list. +* +* @bp: device handle +* @o: vlan_mac object +* +* @details: Non-blocking implementation; should be called under execution +* queue lock. +*/ +static int __bnx2x_vlan_mac_h_write_trylock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +if (o->head_writer || o->head_reader) { +DP (BNX2X_MSG_SP ,"vlan_mac_lock writer - Can't take; Busy\n" ); +return -EBUSY ; + } + + o->head_writer = true; + o->head_exe = true; +DP (BNX2X_MSG_SP ,"vlan_mac_lock writer - Taken\n" ); +return 0 ; +} + +/** +* __bnx2x_vlan_mac_h_write_lock - takes writer lock on vlan mac head list +* +* @bp: device handle +* @o: vlan_mac object +* +* @details May sleep. Should be called under execution queue lock; notice it +* might release and reclaim it during its run. +*/ +static int __bnx2x_vlan_mac_h_write_lock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +spinlock_t *lock = &o->exe_queue.lock; +int rc =0 , time_left =BNX2X_VLAN_MAC_H_LOCK_TIMEOUT ; + +DP (BNX2X_MSG_SP ,"vlan_mac_lock - Trying to lock writer...\n" ); +while (time_left && + (__bnx2x_vlan_mac_h_write_trylock (bp, o) !=0 )) { +spin_unlock_bh (lock); +usleep_range (1000 ,2000 ); + time_left--; +spin_lock_bh (lock); + } + +if (!time_left) { +BNX2X_ERR ("Failed to get vlan_mac_lock (writer)\n" ); +#ifdef BNX2X_STOP_ON_ERROR +bnx2x_panic (); +#endif + rc = -EBUSY ; + }else { +DP (BNX2X_MSG_SP ,"Got vlan_mac_lock (writer) after %d iterations\n" , +BNX2X_VLAN_MAC_H_LOCK_TIMEOUT - time_left); + } + +return rc; +} + +/** +* bnx2x_vlan_mac_h_write_lock - takes writer lock on vlan mac head list +* +* @bp: device handle +* @o: vlan_mac object +* +* @details May sleep. Notice it claims & releases the execution queue's lock. +*/ +int bnx2x_vlan_mac_h_write_lock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +int rc; + +spin_lock_bh (&o->exe_queue.lock); + rc =__bnx2x_vlan_mac_h_write_lock (bp, o); +spin_unlock_bh (&o->exe_queue.lock); + +return rc; +} + +/** +* __bnx2x_vlan_mac_h_exec_pending - execute step instead of a previous step +* which wasn't able to run due to a taken lock on vlan mac head list. +* +* @bp: device handle +* @o: vlan_mac object +* +* @details Should be called under execution queue lock; notice it might release +* and reclaim it during its run. +*/ +static void __bnx2x_vlan_mac_h_exec_pending (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +int rc; +unsigned long ramrod_flags = o->saved_ramrod_flags; + +if (!o->head_writer) { +BNX2X_ERR ("vlan_mac_lock - Need to execute pending command, but writer isn't marked\n" ); +#ifdef BNX2X_STOP_ON_ERROR +bnx2x_panic (); +#endif + } + +DP (BNX2X_MSG_SP ,"vlan_mac_lock execute pending command with ramrod flags %lu\n" , + ramrod_flags); + o->head_exe = true; + o->head_exe_request = false; + o->saved_ramrod_flags =0 ; +spin_unlock_bh (&o->exe_queue.lock); + rc =bnx2x_exe_queue_step (bp, o, &o->exe_queue, &ramrod_flags); +if (rc !=0 ) { +BNX2X_ERR ("execution of pending commands failed with rc %d\n" , + rc); +#ifdef BNX2X_STOP_ON_ERROR +bnx2x_panic (); +#endif + } +spin_lock_bh (&o->exe_queue.lock); +} + +/** +* __bnx2x_vlan_mac_h_pend - Pend an execution step which couldn't have been +* called due to vlan mac head list lock being taken. +* +* @bp: device handle +* @o: vlan_mac object +* @ramrod_flags: ramrod flags of missed execution +* +* @details Should be called under execution queue lock. +*/ +static void __bnx2x_vlan_mac_h_pend (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o, +unsigned long ramrod_flags) +{ +if (!o->head_exe) { + o->head_exe_request = true; + o->saved_ramrod_flags = ramrod_flags; +DP (BNX2X_MSG_SP ,"Placing pending execution with ramrod flags %lu\n" , + ramrod_flags); + }else { +/* Since an executor is on the field, he will step whatever +* we do. We can simply cease - no need to pend a command. +*/ +DP (BNX2X_MSG_SP ,"Skipping pending execution with ramrod flags %lu\n" , + ramrod_flags); + } +} + +/** +* __bnx2x_vlan_mac_h_write_unlock - unlock the vlan mac head list writer lock +* +* @bp: device handle +* @o: vlan_mac object +* +* @details Should be called under execution queue lock. Notice if a pending +* execution exists, it would perform it - possibly releasing and +* reclaiming the execution queue lock. +*/ +static void __bnx2x_vlan_mac_h_write_unlock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +/* When releasing a writer lock, exec. was supposed to prev. happen */ +if (!o->head_writer) { +BNX2X_ERR ("Need to release vlan mac writer lock, but lock isn't taken properly (%d)\n" , + o->head_writer); +#ifdef BNX2X_STOP_ON_ERROR +bnx2x_panic (); +#endif + } +if (o->head_exe) +BNX2X_ERR ("Need to release vlan mac writer lock, but execution wasn't performed (%d)\n" , + o->head_exe); + +/* It's possible a new pending execution was added since this writer +* executed. If so, execute again. [Ad infinitum] +*/ +while (o->head_exe_request) { +DP (BNX2X_MSG_SP ,"vlan_mac_lock - writer release encountered a pending request\n" ); +__bnx2x_vlan_mac_h_exec_pending (bp, o); + } + + o->head_writer = false; +} + +/** +* bnx2x_vlan_mac_h_write_unlock - unlock the vlan mac head list writer lock +* +* @bp: device handle +* @o: vlan_mac object +* +* @details Notice if a pending execution exists, it would perform it - +* possibly releasing and reclaiming the execution queue lock. +*/ +void bnx2x_vlan_mac_h_write_unlock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +spin_lock_bh (&o->exe_queue.lock); +__bnx2x_vlan_mac_h_write_unlock (bp, o); +spin_unlock_bh (&o->exe_queue.lock); +} + +/** +* __bnx2x_vlan_mac_h_read_lock - lock the vlan mac head list reader lock +* +* @bp: device handle +* @o: vlan_mac object +* +* @details Should be called under the execution queue lock. May sleep. May +* release and reclaim execution queue lock during its run. +*/ +static int __bnx2x_vlan_mac_h_read_lock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +spinlock_t *lock = &o->exe_queue.lock; +int rc =0 , time_left =BNX2X_VLAN_MAC_H_LOCK_TIMEOUT ; + +DP (BNX2X_MSG_SP ,"vlan_mac_lock - Trying to lock reader...\n" ); +while (time_left && o->head_writer) { +spin_unlock_bh (lock); +usleep_range (1000 ,2000 ); + time_left--; +spin_lock_bh (lock); + } + +if (!time_left) { +BNX2X_ERR ("vlan_mac_lock - Failed to get reader lock\n" ); +#ifdef BNX2X_STOP_ON_ERROR +bnx2x_panic (); +#endif + rc = -EBUSY ; + }else { + o->head_reader++; +DP (BNX2X_MSG_SP ,"vlan_mac_lock - locked reader - number %d\n" , + o->head_reader); + } + +return rc; +} + +/** +* bnx2x_vlan_mac_h_read_lock - lock the vlan mac head list reader lock +* +* @bp: device handle +* @o: vlan_mac object +* +* @details May sleep. Claims and releases execution queue lock during its run. +*/ +int bnx2x_vlan_mac_h_read_lock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +int rc; + +spin_lock_bh (&o->exe_queue.lock); + rc =__bnx2x_vlan_mac_h_read_lock (bp, o); +spin_unlock_bh (&o->exe_queue.lock); + +return rc; +} + +/** +* __bnx2x_vlan_mac_h_read_unlock - unlock the vlan mac head list reader lock +* +* @bp: device handle +* @o: vlan_mac object +* +* @details Should be called under execution queue lock. Notice if a pending +* execution exists, it would be performed if this was the last +* reader. possibly releasing and reclaiming the execution queue lock. +*/ +static void __bnx2x_vlan_mac_h_read_unlock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +if (!o->head_reader) { +BNX2X_ERR ("Need to release vlan mac reader lock, but lock isn't taken\n" ); +#ifdef BNX2X_STOP_ON_ERROR +bnx2x_panic (); +#endif + }else { + o->head_reader--; +DP (BNX2X_MSG_SP ,"vlan_mac_lock - decreased readers to %d\n" , + o->head_reader); + } + +/* It's possible a new pending execution was added, and that this reader +* was last - if so we need to execute the command. +*/ +if (!o->head_reader && o->head_exe_request) { +DP (BNX2X_MSG_SP ,"vlan_mac_lock - reader release encountered a pending request\n" ); + +/* Writer release will do the trick */ + o->head_writer = true; +__bnx2x_vlan_mac_h_write_unlock (bp, o); + } +} + +/** +* bnx2x_vlan_mac_h_read_unlock - unlock the vlan mac head list reader lock +* +* @bp: device handle +* @o: vlan_mac object +* +* @details Notice if a pending execution exists, it would be performed if this +* was the last reader. Claims and releases the execution queue lock +* during its run. +*/ +void bnx2x_vlan_mac_h_read_unlock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o) +{ +spin_lock_bh (&o->exe_queue.lock); +__bnx2x_vlan_mac_h_read_unlock (bp, o); +spin_unlock_bh (&o->exe_queue.lock); +} +static int bnx2x_get_n_elements (struct bnx2x *bp,struct bnx2x_vlan_mac_obj *o,int n,u8 *buf) {struct bnx2x_vlan_mac_registry_elem *pos;u8 *next = buf; -int counter =0 ; +int counter =0 , read_lock; + +DP (BNX2X_MSG_SP ,"get_n_elements - taking vlan_mac_lock (reader)\n" ); + read_lock =bnx2x_vlan_mac_h_read_lock (bp, o); +if (read_lock !=0 ) +BNX2X_ERR ("get_n_elements failed to get vlan mac reader lock; Access without lock\n" );/* traverse list */ list_for_each_entry (pos, &o->head, link) {
@@ -470,6 +799,12 @@ static int bnx2x_get_n_elements(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o, counter, next, pos->u.mac.mac); } } + +if (read_lock ==0 ) { +DP (BNX2X_MSG_SP ,"get_n_elements - releasing vlan_mac_lock (reader)\n" ); +bnx2x_vlan_mac_h_read_unlock (bp, o); + } +return counter *ETH_ALEN ; }
@@ -1095,7 +1430,7 @@ static int bnx2x_vlan_mac_restore(struct bnx2x *bp,/* Set a restore bit */ __set_bit (RAMROD_RESTORE , &p->ramrod_flags); -return bnx2x_config_vlan_mac (bp, p); +return bnx2x_config_vlan_mac_locked (bp, p); }/*
@@ -1417,6 +1752,52 @@ static int bnx2x_wait_vlan_mac(struct bnx2x *bp,return -EBUSY ; } +static int __bnx2x_vlan_mac_execute_step (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o, +unsigned long *ramrod_flags, +bool pre_locked) +{ +bool current_lock; +int rc; + +spin_lock_bh (&o->exe_queue.lock); + +if (!pre_locked) { +DP (BNX2X_MSG_SP ,"vlan_mac_execute_step - trying to take writer lock\n" ); + rc =__bnx2x_vlan_mac_h_write_trylock (bp, o); + current_lock = (rc ==0 ) ? true : false; + }else { +/* Since there's an outside lock, it's possible there've +* been repeated calls to this functions. As every call to +* exe_queue_step would clear the execution index, we need +* to clean any pending request to execute and re-set the +* execution status. +*/ + o->head_exe_request = false; + o->saved_ramrod_flags =0 ; + o->head_exe = true; + + current_lock = true; + } + +if (!current_lock) { +__bnx2x_vlan_mac_h_pend (bp, o, *ramrod_flags); +spin_unlock_bh (&o->exe_queue.lock); + }else { +spin_unlock_bh (&o->exe_queue.lock); + + rc =bnx2x_exe_queue_step (bp, o, &o->exe_queue, ramrod_flags); +if (!pre_locked) { +DP (BNX2X_MSG_SP ,"vlan_mac_execute_step - trying to release writer lock\n" ); +bnx2x_vlan_mac_h_write_unlock (bp, o); + } +if (rc <0 ) +return rc; + } + +return 0 ; +} +/** * bnx2x_complete_vlan_mac - complete one VLAN-MAC ramrod *
@@ -1446,7 +1827,9 @@ static int bnx2x_complete_vlan_mac(struct bnx2x *bp,/* Run the next bulk of pending commands if requested */ if (test_bit (RAMROD_CONT , ramrod_flags)) { - rc =bnx2x_exe_queue_step (bp, &o->exe_queue, ramrod_flags); + rc =__bnx2x_vlan_mac_execute_step (bp, o, + ramrod_flags, false); +if (rc <0 )return rc; }
@@ -1737,15 +2120,15 @@ static inline int bnx2x_vlan_mac_push_new_cmd( }/** -* bnx2x_config_vlan_mac - configure VLAN/MAC/VLAN_MAC filtering rules. +* __bnx2x_config_vlan_mac - configure VLAN/MAC/VLAN_MAC filtering rules. * * @bp: device handle * @p: * */ -int bnx2x_config_vlan_mac ( -struct bnx2x *bp, -struct bnx2x_vlan_mac_ramrod_params *p) +static int __bnx2x_config_vlan_mac (struct bnx2x *bp, +struct bnx2x_vlan_mac_ramrod_params *p, +bool pre_locked) {int rc =0 ;struct bnx2x_vlan_mac_obj *o = p->vlan_mac_obj;
@@ -1777,7 +2160,9 @@ int bnx2x_config_vlan_mac(/* Execute commands if required */ if (cont ||test_bit (RAMROD_EXEC , ramrod_flags) ||test_bit (RAMROD_COMP_WAIT , ramrod_flags)) { - rc =bnx2x_exe_queue_step (bp, &o->exe_queue, ramrod_flags); + rc =__bnx2x_vlan_mac_execute_step (bp, p->vlan_mac_obj, + &p->ramrod_flags, + pre_locked);if (rc <0 )return rc; }
@@ -1802,8 +2187,10 @@ int bnx2x_config_vlan_mac(return rc;/* Make a next step */ - rc =bnx2x_exe_queue_step (bp, &o->exe_queue, - ramrod_flags); + rc =__bnx2x_vlan_mac_execute_step (bp, + p->vlan_mac_obj, + &p->ramrod_flags, + pre_locked);if (rc <0 )return rc; }
@@ -1814,7 +2201,17 @@ int bnx2x_config_vlan_mac(return rc; } +int bnx2x_config_vlan_mac (struct bnx2x *bp, +struct bnx2x_vlan_mac_ramrod_params *p) +{ +return __bnx2x_config_vlan_mac (bp, p, false); +} +int bnx2x_config_vlan_mac_locked (struct bnx2x *bp, +struct bnx2x_vlan_mac_ramrod_params *p) +{ +return __bnx2x_config_vlan_mac (bp, p, true); +}/** * bnx2x_vlan_mac_del_all - delete elements with given vlan_mac_flags spec
@@ -1835,7 +2232,7 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp, unsigned long *ramrod_flags) {struct bnx2x_vlan_mac_registry_elem *pos =NULL ; -int rc =0 ; +int rc =0 , read_lock;struct bnx2x_vlan_mac_ramrod_params p;struct bnx2x_exe_queue_obj *exeq = &o->exe_queue;struct bnx2x_exeq_elem *exeq_pos, *exeq_pos_n;
@@ -1873,6 +2270,11 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,__clear_bit (RAMROD_EXEC , &p.ramrod_flags);__clear_bit (RAMROD_CONT , &p.ramrod_flags); +DP (BNX2X_MSG_SP ,"vlan_mac_del_all -- taking vlan_mac_lock (reader)\n" ); + read_lock =bnx2x_vlan_mac_h_read_lock (bp, o); +if (read_lock !=0 ) +return read_lock; +list_for_each_entry (pos, &o->head, link) {if (pos->vlan_mac_flags == *vlan_mac_flags) { p.user_req.vlan_mac_flags = pos->vlan_mac_flags;
@@ -1880,11 +2282,15 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp, rc =bnx2x_config_vlan_mac (bp, &p);if (rc <0 ) {BNX2X_ERR ("Failed to add a new DEL command\n" ); +bnx2x_vlan_mac_h_read_unlock (bp, o);return rc; } } } +DP (BNX2X_MSG_SP ,"vlan_mac_del_all -- releasing vlan_mac_lock (reader)\n" ); +bnx2x_vlan_mac_h_read_unlock (bp, o); + p.ramrod_flags = *ramrod_flags;__set_bit (RAMROD_CONT , &p.ramrod_flags);
@@ -1916,6 +2322,11 @@ static inline void bnx2x_init_vlan_mac_common(struct bnx2x_vlan_mac_obj *o, struct bnx2x_credit_pool_obj *vlans_pool) {INIT_LIST_HEAD (&o->head); + o->head_writer = false; + o->head_reader =0 ; + o->head_exe = false; + o->head_exe_request = false; + o->saved_ramrod_flags =0 ; o->macs_pool = macs_pool; o->vlans_pool = vlans_pool;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +18 -0
@@ -290,6 +290,14 @@ struct bnx2x_vlan_mac_obj {* entries. */ struct list_head head; +/* Implement a simple reader/writer lock on the head list. +* all these fields should only be accessed under the exe_queue lock +*/ +bool head_writer;/* Writer accessing head list. */ +bool head_exe;/* Writer will exec a step */ +u8 head_reader;/* Num. of readers accessing head list */ +bool head_exe_request;/* Pending execution request. */ +unsigned long saved_ramrod_flags;/* Ramrods of pending execution */ /* TODO: Add it's initialization in the init functions */ struct bnx2x_exe_queue_obj exe_queue;
@@ -1297,8 +1305,18 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,struct bnx2x_credit_pool_obj *macs_pool, struct bnx2x_credit_pool_obj *vlans_pool); +int bnx2x_vlan_mac_h_read_lock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o); +void bnx2x_vlan_mac_h_read_unlock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o); +int bnx2x_vlan_mac_h_write_lock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o); +void bnx2x_vlan_mac_h_write_unlock (struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o);int bnx2x_config_vlan_mac (struct bnx2x *bp,struct bnx2x_vlan_mac_ramrod_params *p); +int bnx2x_config_vlan_mac_locked (struct bnx2x *bp, +struct bnx2x_vlan_mac_ramrod_params *p); int bnx2x_vlan_mac_move(struct bnx2x *bp, struct bnx2x_vlan_mac_ramrod_params *p,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +8 -1
@@ -489,12 +489,19 @@ static inline void bnx2x_vfop_credit(struct bnx2x *bp,* and a valid credit counter */ if (!vfop->rc && args->credit) { -int cnt =0 ; +int cnt =0 , read_lock;struct list_head *pos; + read_lock =bnx2x_vlan_mac_h_read_lock (bp, obj); +if (read_lock) +DP (BNX2X_MSG_SP ,"Failed to take vlan mac read head; continuing anyway\n" ); +list_for_each (pos, &obj->head) cnt++; +if (!read_lock) +bnx2x_vlan_mac_h_read_unlock (bp, obj); +atomic_set (args->credit, cnt); } }
Signature · 1 line
1.7.9.GIT
PATCH 2/9 bnx2x: fix vlan-mac memory leak
In reply to Yuval MintzThis patch releases memory previously simply omitted when elements are removed from pending execution lists in the bnx2x driver.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +1 -0
@@ -2251,6 +2251,7 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,return rc; }list_del (&exeq_pos->link); +bnx2x_exe_queue_free_elem (bp, exeq_pos); } }
Signature · 1 line
1.7.9.GIT
PATCH 3/9 bnx2x: handle spurious interrupts
In reply to Yuval MintzIn scenarios in which a previous driver was removed without proper cleanup (e.g., kdump), it is possible for the chip to generate an interrupt without any apparent reason.
This would cause improper behaviour at best, possibly resulting in NULL pointer dereferences as interrupts might be sent to an ISR accessing uninitialized structures and memories.
This causes the driver to ignore any interrupt which arrives in an inappropriate time, i.e., when the driver has not yet properly configured its interrupt routines.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 11 +++++++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 +++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 3 ++- 4 files changed, 17 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +1 -0
@@ -1379,6 +1379,7 @@ struct bnx2x {#define USING_SINGLE_MSIX_FLAG (1 << 20)#define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21)#define IS_VF_FLAG (1 << 22) +#define INTERRUPTS_ENABLED_FLAG (1 << 23)#define BP_NOMCP (bp) ((bp)->flags & NO_MCP_FLAG)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +11 -0
@@ -1037,6 +1037,17 @@ static irqreturn_t bnx2x_msix_fp_int(int irq, void *fp_cookie)DP (NETIF_MSG_INTR ,"got an MSI-X interrupt on IDX:SB [fp %d fw_sd %d igusb %d]\n" , fp->index, fp->fw_sb_id, fp->igu_sb_id); + +/* It's possible for a spurious interrupt to be received, if the +* driver was loaded above a previous configured function (e.g., kdump). +* We simply ignore such interrupts. +*/ +if (unlikely (!(bp->flags &INTERRUPTS_ENABLED_FLAG ))) { +WARN_ONCE (1 ,"%s: Got Spurious interrupts" , + bp->dev ? bp->dev->name :"?" ); +return IRQ_HANDLED ; + } +bnx2x_ack_sb (bp, fp->igu_sb_id,USTORM_ID ,0 ,IGU_INT_DISABLE ,0 );#ifdef BNX2X_STOP_ON_ERROR
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +3 -0
@@ -868,6 +868,7 @@ static void bnx2x_int_disable(struct bnx2x *bp)bnx2x_hc_int_disable (bp); elsebnx2x_igu_int_disable (bp ); + bp->flags &= ~INTERRUPTS_ENABLED_FLAG ; }void bnx2x_panic_dump (struct bnx2x *bp,bool disable_int)
@@ -1607,6 +1608,8 @@ static void bnx2x_igu_int_enable(struct bnx2x *bp)void bnx2x_int_enable (struct bnx2x *bp) { + bp->flags |=INTERRUPTS_ENABLED_FLAG ; +if (bp->common.int_block ==INT_BLOCK_HC )bnx2x_hc_int_enable (bp);else
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +2 -1
@@ -268,7 +268,8 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count) bp->mf_mode =0 ; bp->common.flash_size =0 ; bp->flags |= -NO_WOL_FLAG |NO_ISCSI_OOO_FLAG |NO_ISCSI_FLAG |NO_FCOE_FLAG ; +NO_WOL_FLAG |NO_ISCSI_OOO_FLAG |NO_ISCSI_FLAG |NO_FCOE_FLAG | +INTERRUPTS_ENABLED_FLAG ; bp->igu_sb_cnt =1 ; bp->igu_base_sb = bp->acquire_resp.resc.hw_sbs[0 ].hw_sb_id; strlcpy(bp->fw_ver, bp->acquire_resp.pfdev_info.fw_ver,
Signature · 1 line
1.7.9.GIT
David Miller
maintainerRe: [PATCH net-next 3/9] bnx2x: handle spurious interrupts
From: "Yuval Mintz" <[email protected]>
Date: Mon, 18 Feb 2013 10:16:32 +0200
Quoted 7 lines
In scenarios in which a previous driver was removed without proper cleanup (e.g., kdump), it is possible for the chip to generate an interrupt without any apparent reason.
This would cause improper behaviour at best, possibly resulting in NULL pointer dereferences as interrupts might be sent to an ISR accessing uninitialized structures and memories.
Quoted 7 lines
This causes the driver to ignore any interrupt which arrives in an inappropriate time, i.e., when the driver has not yet properly configured its interrupt routines.
Signed-off-by Yuval Mintz <[email protected]>Signed-off-by Ariel Elior <[email protected]>Signed-off-by Eilon Greenstein <[email protected]>
I cannot accept this patch.
You must not request_irq() until your software state is completely setup, there are no exceptions to this rule.
PATCH 4/9 bnx2x: Set ethtool ops for vfs
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
Virtual functions don't have access to HW registers, therefore most ethtool ops are forbidden to them. Instead of checking in each op whether the device being driven is a virtual function or a physical function, this patch creates a separate ethtool ops struct for virtual functions and uses it to initialize the ethtool ops of the driver in case it is driving a virtual function device.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 29 ++++++++++++++++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +1 -1
@@ -2287,7 +2287,7 @@ static const u32 dmae_reg_go_c[] = { DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15 }; -void bnx2x_set_ethtool_ops (struct net_device *netdev); +void bnx2x_set_ethtool_ops (struct bnx2x *bp,struct net_device *netdev);void bnx2x_notify_link_changed (struct bnx2x *bp);#define BNX2X_MF_SD_PROTOCOL (bp) \
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +27 -2
@@ -3226,7 +3226,32 @@ static const struct ethtool_ops bnx2x_ethtool_ops = { .get_ts_info = ethtool_op_get_ts_info, }; -void bnx2x_set_ethtool_ops (struct net_device *netdev) +static const struct ethtool_ops bnx2x_vf_ethtool_ops = { + .get_settings = bnx2x_get_settings, + .set_settings = bnx2x_set_settings, + .get_drvinfo = bnx2x_get_drvinfo, + .get_msglevel = bnx2x_get_msglevel, + .set_msglevel = bnx2x_set_msglevel, + .get_link = bnx2x_get_link, + .get_coalesce = bnx2x_get_coalesce, + .get_ringparam = bnx2x_get_ringparam, + .set_ringparam = bnx2x_set_ringparam, + .get_sset_count = bnx2x_get_sset_count, + .get_strings = bnx2x_get_strings, + .get_ethtool_stats = bnx2x_get_ethtool_stats, + .get_rxnfc = bnx2x_get_rxnfc, + .set_rxnfc = bnx2x_set_rxnfc, + .get_rxfh_indir_size = bnx2x_get_rxfh_indir_size, + .get_rxfh_indir = bnx2x_get_rxfh_indir, + .set_rxfh_indir = bnx2x_set_rxfh_indir, + .get_channels = bnx2x_get_channels, + .set_channels = bnx2x_set_channels, +}; + +void bnx2x_set_ethtool_ops (struct bnx2x *bp,struct net_device *netdev) { -SET_ETHTOOL_OPS (netdev, &bnx2x_ethtool_ops); +if (IS_PF (bp)) +SET_ETHTOOL_OPS (netdev, &bnx2x_ethtool_ops); +else /* vf */ +SET_ETHTOOL_OPS (netdev, &bnx2x_vf_ethtool_ops); }
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -1
@@ -11956,7 +11956,7 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev, dev->watchdog_timeo =TX_TIMEOUT ; dev->netdev_ops = &bnx2x_netdev_ops; -bnx2x_set_ethtool_ops (dev); +bnx2x_set_ethtool_ops (bp, dev); dev->priv_flags |=IFF_UNICAST_FLT ;
Signature · 1 line
1.7.9.GIT
PATCH 5/9 bnx2x: Take chip version from MFW
In reply to Yuval MintzIn latest boards, the CHIP_METAL register contains an incorrect revision value, so the correct one needs to be obtained in a different manner.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 ++++++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +6 -2
@@ -10037,8 +10037,12 @@ static void bnx2x_get_common_hwinfo(struct bnx2x *bp) id = ((val &0xffff ) <<16 ); val =REG_RD (bp,MISC_REG_CHIP_REV ); id |= ((val &0xf ) <<12 ); - val =REG_RD (bp,MISC_REG_CHIP_METAL ); - id |= ((val &0xff ) <<4 ); + +/* Metal is read from PCI regs, but we can't access >=0x400 from +* the configuration space (so we need to reg_rd) +*/ + val =REG_RD (bp,PCICFG_OFFSET +PCI_ID_VAL3 ); + id |= (((val >>24 ) &0xf ) <<4 ); val =REG_RD (bp,MISC_REG_BOND_ID ); id |= (val &0xf ); bp->common.chip_id = id;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h +2 -4
@@ -1491,10 +1491,6 @@/* [R 4] This field indicates the type of the device. '0' - 2 Ports; '1' - 1 Port. */ #define MISC_REG_BOND_ID 0xa400 -/* [R 8] These bits indicate the metal revision of the chip. This value -starts at 0x00 for each all-layer tape-out and increments by one for each -tape-out. */ -#define MISC_REG_CHIP_METAL 0xa404/* [R 16] These bits indicate the part number for the chip. */ #define MISC_REG_CHIP_NUM 0xa408/* [R 4] These bits indicate the base revision of the chip. This value
@@ -6331,6 +6327,8 @@#define PCI_PM_DATA_B 0x414#define PCI_ID_VAL1 0x434#define PCI_ID_VAL2 0x438 +#define PCI_ID_VAL3 0x43c +#define GRC_CONFIG_REG_PF_INIT_VF 0x624#define GRC_CR_PF_INIT_VF_PF_FIRST_VF_NUM_MASK 0xf/* First VF_NUM for PF is encoded in this register.
Signature · 1 line
1.7.9.GIT
PATCH 6/9 bnx2x: Prevent "Unknown MF" print in SF mode
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
When using a chip operating in Single Function mode, when the chip is probed the bnx2x would print a message warning of an unknown Multi Function mode.
This patch prevents said message.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +3 -0
@@ -11063,6 +11063,9 @@ static int bnx2x_get_hwinfo(struct bnx2x *bp) }else BNX2X_DEV_INFO ("illegal OV for SD\n" );break ; +case SHARED_FEAT_CFG_FORCE_SF_MODE_FORCED_SF : + bp->mf_config[vn] =0 ; +break ;default :/* Unknown configuration: reset mf_config */ bp->mf_config[vn] =0 ;
Signature · 1 line
1.7.9.GIT
PATCH 7/9 bnx2x: Add iproute2 support for vfs
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
This patch adds support for iproute2 callbacks allowing querying a physical function as to its child virtual functions, and setting the macs and vlans of said virtual functions.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 3 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 39 +++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 24 +-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 6 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 231 +++++++++++++++++++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h | 3 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h | 9 +- 8 files changed, 270 insertions(+), 46 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +1 -0
@@ -1215,6 +1215,7 @@ enum {BNX2X_SP_RTNL_ENABLE_SRIOV ,BNX2X_SP_RTNL_VFPF_MCAST ,BNX2X_SP_RTNL_VFPF_STORM_RX_MODE , + BNX2X_SP_RTNL_HYPERVISOR_VLAN, };
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +3 -0
@@ -496,7 +496,10 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);/* setup_tc callback */ int bnx2x_setup_tc (struct net_device *dev,u8 num_tc); +int bnx2x_get_vf_config (struct net_device *dev,int vf, +struct ifla_vf_info *ivi);int bnx2x_set_vf_mac (struct net_device *dev,int queue,u8 *mac); +int bnx2x_set_vf_vlan (struct net_device *netdev,int vf,u16 vlan,u8 qos);/* select_queue callback */ u16 bnx2x_select_queue (struct net_device *dev,struct sk_buff *skb);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +28 -11
@@ -75,8 +75,6 @@#define FW_FILE_NAME_E1H "bnx2x/bnx2x-e1h-" FW_FILE_VERSION ".fw"#define FW_FILE_NAME_E2 "bnx2x/bnx2x-e2-" FW_FILE_VERSION ".fw" -#define MAC_LEADING_ZERO_CNT (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN) -/* Time in jiffies before concluding the transmitter is hung */ #define TX_TIMEOUT (5*HZ)
@@ -3230,16 +3228,29 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x *bp) {struct eth_stats_info *ether_stat = &bp->slowpath->drv_info_to_mcp.ether_stat; +struct bnx2x_vlan_mac_obj *mac_obj = + &bp->sp_objs->mac_obj; +int i;strlcpy (ether_stat->version,DRV_MODULE_VERSION ,ETH_STAT_INFO_VERSION_LEN ); - bp->sp_objs[0 ].mac_obj.get_n_elements (bp, &bp->sp_objs[0 ].mac_obj, -DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED , - ether_stat->mac_local); - +/* get DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED macs, placing them in the +* mac_local field in ether_stat struct. The base address is offset by 2 +* bytes to account for the field being 8 bytes but a mac address is +* only 6 bytes. Likewise, the stride for the get_n_elements function is +* 2 bytes to compensate from the 6 bytes of a mac to the 8 bytes +* allocated by the ether_stat struct, so the macs will land in their +* proper positions. +*/ +for (i =0 ; i <DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED ; i++) +memset (ether_stat->mac_local + i,0 , +sizeof (ether_stat->mac_local[0 ])); + mac_obj->get_n_elements (bp, &bp->sp_objs[0 ].mac_obj, +DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED , + ether_stat->mac_local +MAC_PAD ,MAC_PAD , +ETH_ALEN ); ether_stat->mtu_size = bp->dev->mtu; -if (bp->dev->features &NETIF_F_RXCSUM ) ether_stat->feature_flags |=FEATURE_ETH_CHKSUM_OFFLOAD_MASK ;if (bp->dev->features &NETIF_F_TSO )
@@ -3261,8 +3272,7 @@ static void bnx2x_drv_info_fcoe_stat(struct bnx2x *bp)if (!CNIC_LOADED (bp))return ; -memcpy (fcoe_stat->mac_local +MAC_LEADING_ZERO_CNT , - bp->fip_mac,ETH_ALEN ); +memcpy (fcoe_stat->mac_local +MAC_PAD , bp->fip_mac,ETH_ALEN ); fcoe_stat->qos_priority = app->traffic_type_priority[LLFC_TRAFFIC_TYPE_FCOE ];
@@ -3364,8 +3374,8 @@ static void bnx2x_drv_info_iscsi_stat(struct bnx2x *bp)if (!CNIC_LOADED (bp))return ; -memcpy (iscsi_stat->mac_local +MAC_LEADING_ZERO_CNT , - bp->cnic_eth_dev.iscsi_mac,ETH_ALEN ); +memcpy (iscsi_stat->mac_local +MAC_PAD , bp->cnic_eth_dev.iscsi_mac, +ETH_ALEN ); iscsi_stat->qos_priority = app->traffic_type_priority[LLFC_TRAFFIC_TYPE_ISCSI ];
@@ -9528,6 +9538,11 @@ sp_rtnl_not_reset:bnx2x_vfpf_storm_rx_mode (bp); } +if (test_and_clear_bit (BNX2X_SP_RTNL_HYPERVISOR_VLAN , + &bp->sp_rtnl_state)) { +bnx2x_pf_set_vfs_vlan (bp); + } +/* work which needs rtnl lock not-taken (as it takes the lock itself and * can be called from other contexts as well) */
@@ -11801,6 +11816,8 @@ static const struct net_device_ops bnx2x_netdev_ops = { .ndo_setup_tc = bnx2x_setup_tc,#ifdef CONFIG_BNX2X_SRIOV .ndo_set_vf_mac = bnx2x_set_vf_mac, + .ndo_set_vf_vlan = bnx2x_set_vf_vlan, + .ndo_get_vf_config = bnx2x_get_vf_config,#endif #ifdef NETDEV_FCOE_WWNN .ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +7 -17
@@ -30,8 +30,6 @@#define BNX2X_MAX_EMUL_MULTI 16 -#define MAC_LEADING_ZERO_CNT (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN) -/**** Exe Queue interfaces ****/ /**
@@ -768,10 +766,10 @@ void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp, }static int bnx2x_get_n_elements (struct bnx2x *bp,struct bnx2x_vlan_mac_obj *o, -int n,u8 *buf) +int n,u8 *base,u8 stride,u8 size) {struct bnx2x_vlan_mac_registry_elem *pos; -u8 *next = buf; +u8 *next = base;int counter =0 , read_lock;DP (BNX2X_MSG_SP ,"get_n_elements - taking vlan_mac_lock (reader)\n" );
@@ -782,21 +780,12 @@ static int bnx2x_get_n_elements(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,/* traverse list */ list_for_each_entry (pos, &o->head, link) {if (counter < n) { -/* place leading zeroes in buffer */ -memset (next,0 ,MAC_LEADING_ZERO_CNT ); - -/* place mac after leading zeroes*/ -memcpy (next +MAC_LEADING_ZERO_CNT , pos->u.mac.mac, -ETH_ALEN ); - -/* calculate address of next element and -* advance counter -*/ +memcpy (next, &pos->u, size); counter++; - next = buf + counter *ALIGN (ETH_ALEN ,sizeof (u32)); +DP (BNX2X_MSG_SP ,"copied element number %d to address %p element was:\n" , + counter, next); + next += stride + size; -DP (BNX2X_MSG_SP ,"copied element number %d to address %p element was %pM\n" , - counter, next, pos->u.mac.mac); } }
@@ -2424,6 +2413,7 @@ void bnx2x_init_vlan_obj(struct bnx2x *bp, vlan_obj->check_move = bnx2x_check_move; vlan_obj->ramrod_cmd =RAMROD_CMD_ID_ETH_CLASSIFICATION_RULES ; + vlan_obj->get_n_elements = bnx2x_get_n_elements;/* Exe Queue */ bnx2x_exe_queue_init(bp,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +4 -2
@@ -321,8 +321,9 @@ struct bnx2x_vlan_mac_obj {* * @return number of copied bytes */ -int (*get_n_elements)(struct bnx2x *bp,struct bnx2x_vlan_mac_obj *o, -int n,u8 *buf); +int (*get_n_elements)(struct bnx2x *bp, +struct bnx2x_vlan_mac_obj *o,int n,u8 *base, +u8 stride,u8 size);/** * Checks if ADD-ramrod with the given params may be performed.
@@ -850,6 +851,7 @@ enum bnx2x_q_type {#define BNX2X_MULTI_TX_COS_E3B0 3#define BNX2X_MULTI_TX_COS 3/* Maximum possible */ +#define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN) struct bnx2x_queue_init_params { struct {
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +216 -15
285 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h +3 -0
@@ -193,6 +193,7 @@ struct bnx2x_virtf {#define VF_CFG_TPA 0x0004#define VF_CFG_INT_SIMD 0x0008#define VF_CACHE_LINE 0x0010 +#define VF_CFG_VLAN 0x0020u8 state;#define VF_FREE 0/* VF ready to be acquired holds no resc */
@@ -757,6 +758,7 @@ static inline int bnx2x_vf_headroom(struct bnx2x *bp) {return bp->vfdb->sriov.nr_virtfn *BNX2X_CLIENTS_PER_VF ; } +void bnx2x_pf_set_vfs_vlan (struct bnx2x *bp);#else /* CONFIG_BNX2X_SRIOV */
@@ -804,6 +806,7 @@ static inline enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bpstatic inline int bnx2x_vf_map_doorbells (struct bnx2x *bp) {return 0 ; }static inline int bnx2x_vf_pci_alloc (struct bnx2x *bp) {return 0 ; } +static inline void bnx2x_pf_set_vfs_vlan (struct bnx2x *bp) {}#endif /* CONFIG_BNX2X_SRIOV */ #endif /* bnx2x_sriov.h */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h +8 -1
@@ -328,9 +328,15 @@ struct pf_vf_bulletin_content {#define MAC_ADDR_VALID 0/* alert the vf that a new mac address * is available for it */ +#define VLAN_VALID 1/* when set, the vf should not access +* the vfpf channel +*/ u8 mac[ETH_ALEN ]; -u8 padding[2 ]; +u8 mac_padding[2 ]; + +u16 vlan; +u8 vlan_padding[6 ]; };union pf_vf_bulletin {
@@ -353,6 +359,7 @@ enum channel_tlvs {CHANNEL_TLV_LIST_END ,CHANNEL_TLV_FLR ,CHANNEL_TLV_PF_SET_MAC , +CHANNEL_TLV_PF_SET_VLAN , CHANNEL_TLV_MAX };
Signature · 1 line
1.7.9.GIT
PATCH 8/9 bnx2x: Control number of vfs dynamically
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
1. Support sysfs interface for getting the maximal number of virtual functions of a given physical function.
2. Support sysfs interface for getting and setting the current number of virtual functions.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 2 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 32 ++------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 81 +++++++++++++++++---- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h | 10 ++- 4 files changed, 83 insertions(+), 42 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +2 -0
@@ -1282,6 +1282,8 @@ struct bnx2x {dma_addr_t pf2vf_bulletin_mapping;struct pf_vf_bulletin_content old_bulletin; + +u16 requested_nr_virtfn;#endif /* CONFIG_BNX2X_SRIOV */ struct net_device *dev;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +5 -27
@@ -11427,26 +11427,6 @@ static int bnx2x_init_bp(struct bnx2x *bp)* net_device service functions */ -static int bnx2x_open_epilog (struct bnx2x *bp) -{ -/* Enable sriov via delayed work. This must be done via delayed work -* because it causes the probe of the vf devices to be run, which invoke -* register_netdevice which must have rtnl lock taken. As we are holding -* the lock right now, that could only work if the probe would not take -* the lock. However, as the probe of the vf may be called from other -* contexts as well (such as passthrough to vm failes) it can't assume -* the lock is being held for it. Using delayed work here allows the -* probe code to simply take the lock (i.e. wait for it to be released -* if it is being held). -*/ -smp_mb__before_clear_bit (); -set_bit (BNX2X_SP_RTNL_ENABLE_SRIOV , &bp->sp_rtnl_state); -smp_mb__after_clear_bit (); -schedule_delayed_work (&bp->sp_rtnl_task,0 ); - -return 0 ; -} -/* called with rtnl_lock */ static int bnx2x_open (struct net_device *dev) {
@@ -12502,13 +12482,8 @@ static int bnx2x_init_one(struct pci_dev *pdev, goto init_one_exit; } -/* Enable SRIOV if capability found in configuration space. -* Once the generic SR-IOV framework makes it in from the -* pci tree this will be revised, to allow dynamic control -* over the number of VFs. Right now, change the num of vfs -* param below to enable SR-IOV. -*/ - rc =bnx2x_iov_init_one (bp, int_mode,0 /*num vfs*/ ); +/* Enable SRIOV if capability found in configuration space */ + rc =bnx2x_iov_init_one (bp, int_mode,BNX2X_MAX_NUM_OF_VFS );if (rc) goto init_one_exit;
@@ -12824,6 +12799,9 @@ static struct pci_driver bnx2x_pci_driver = { .suspend = bnx2x_suspend, .resume = bnx2x_resume, .err_handler = &bnx2x_err_handler, +#ifdef CONFIG_BNX2X_SRIOV + .sriov_configure = bnx2x_sriov_configure, +#endif };static int __init bnx2x_init (void )
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +68 -13
100 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h +8 -2
@@ -51,6 +51,8 @@ struct bnx2x_sriov {u16 stride;/* following VF stride */ u32 pgsz;/* page size for BAR alignment */ u8 link;/* Function Dependency Link */ + +u16 requested_nr_virtfn; };/* bars */
@@ -753,12 +755,14 @@ static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,enum sample_bulletin_result bnx2x_sample_bulletin (struct bnx2x *bp);void bnx2x_vf_map_doorbells (struct bnx2x *bp);int bnx2x_vf_pci_alloc (struct bnx2x *bp); -void bnx2x_enable_sriov (struct bnx2x *bp); +int bnx2x_enable_sriov (struct bnx2x *bp);static inline int bnx2x_vf_headroom (struct bnx2x *bp) {return bp->vfdb->sriov.nr_virtfn *BNX2X_CLIENTS_PER_VF ; }void bnx2x_pf_set_vfs_vlan (struct bnx2x *bp); +int bnx2x_sriov_configure (struct pci_dev *dev,int num_vfs); +int bnx2x_open_epilog (struct bnx2x *bp);#else /* CONFIG_BNX2X_SRIOV */
@@ -781,7 +785,7 @@ static inline void bnx2x_iov_init_dmae(struct bnx2x *bp) {}static inline int bnx2x_iov_init_one (struct bnx2x *bp,int int_mode_param,int num_vfs_param) {return 0 ; }static inline void bnx2x_iov_remove_one (struct bnx2x *bp) {} -static inline void bnx2x_enable_sriov (struct bnx2x *bp) {} +static inline int bnx2x_enable_sriov (struct bnx2x *bp) {return 0 ; }static inline int bnx2x_vfpf_acquire (struct bnx2x *bp,u8 tx_count,u8 rx_count) {return 0 ; }static inline int bnx2x_vfpf_release (struct bnx2x *bp) {return 0 ; }
@@ -807,6 +811,8 @@ static inline enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bpstatic inline int bnx2x_vf_map_doorbells (struct bnx2x *bp) {return 0 ; }static inline int bnx2x_vf_pci_alloc (struct bnx2x *bp) {return 0 ; }static inline void bnx2x_pf_set_vfs_vlan (struct bnx2x *bp) {} +static inline int bnx2x_sriov_configure (struct pci_dev *dev,int num_vfs) {return 0 ; } +static inline int bnx2x_open_epilog (struct bnx2x *bp) {return 0 ; }#endif /* CONFIG_BNX2X_SRIOV */ #endif /* bnx2x_sriov.h */
Signature · 1 line
1.7.9.GIT
PATCH 9/9 bnx2x: Get gso_segs from FW
In reply to Yuval Mintz--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +5 -4
@@ -451,7 +451,8 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue,* Compute number of aggregated segments, and gso_type. */ static void bnx2x_set_gro_params (struct sk_buff *skb,u16 parsing_flags, -u16 len_on_bd,unsigned int pkt_len) +u16 len_on_bd,unsigned int pkt_len, +u16 num_of_coalesced_segs) {/* TPA aggregation won't have either IP options or TCP options * other than timestamp or IPv6 extension headers.
@@ -480,8 +481,7 @@ static void bnx2x_set_gro_params(struct sk_buff *skb, u16 parsing_flags,/* tcp_gro_complete() will copy NAPI_GRO_CB(skb)->count * to skb_shinfo(skb)->gso_segs */ -NAPI_GRO_CB (skb)->count =DIV_ROUND_UP (pkt_len - hdrs_len, -skb_shinfo (skb)->gso_size); +NAPI_GRO_CB (skb)->count = num_of_coalesced_segs; } static int bnx2x_alloc_rx_sge(struct bnx2x *bp,
@@ -537,7 +537,8 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,/* This is needed in order to enable forwarding support */ if (frag_size)bnx2x_set_gro_params (skb, tpa_info->parsing_flags, len_on_bd, -le16_to_cpu (cqe->pkt_len)); +le16_to_cpu (cqe->pkt_len), +le16_to_cpu (cqe->num_of_coalesced_segs));#ifdef BNX2X_STOP_ON_ERROR if (pages >min_t (u32,8 ,MAX_SKB_FRAGS ) *SGE_PAGES ) {
Signature · 1 line
1.7.9.GIT