aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom
diff options
context:
space:
mode:
authorYuval Mintz <yuvalmin@broadcom.com>2012-01-23 02:31:51 -0500
committerDavid S. Miller <davem@davemloft.net>2012-01-23 13:58:18 -0500
commit460a25cdaef1a2b6b8e14e371d868aa91b0e72e8 (patch)
tree73772b7a40203946b805df8904a5e95c9152cf54 /drivers/net/ethernet/broadcom
parent4ec7ac1203bcf21f5e3d977c9818b1a56c9ef40d (diff)
bnx2x: credit-leakage fixup on vlan_mac_del_all
Upon insertion of elements into the execution queue, it is validated that there are enough credits to support additional vlan-macs, and the credits are consumed. However, when removing a pending command in `bnx2x_vland_mac_del_all' the consumed credits are not released, which might cause leakage and eventually the inability to add new vlan-macs in certain scenarios. Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c44
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h11
2 files changed, 54 insertions, 1 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 5ac616093f9f..cb6339c35571 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -50,6 +50,7 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp,
50 int exe_len, 50 int exe_len,
51 union bnx2x_qable_obj *owner, 51 union bnx2x_qable_obj *owner,
52 exe_q_validate validate, 52 exe_q_validate validate,
53 exe_q_remove remove,
53 exe_q_optimize optimize, 54 exe_q_optimize optimize,
54 exe_q_execute exec, 55 exe_q_execute exec,
55 exe_q_get get) 56 exe_q_get get)
@@ -66,6 +67,7 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp,
66 67
67 /* Owner specific callbacks */ 68 /* Owner specific callbacks */
68 o->validate = validate; 69 o->validate = validate;
70 o->remove = remove;
69 o->optimize = optimize; 71 o->optimize = optimize;
70 o->execute = exec; 72 o->execute = exec;
71 o->get = get; 73 o->get = get;
@@ -1340,6 +1342,35 @@ static int bnx2x_validate_vlan_mac(struct bnx2x *bp,
1340 } 1342 }
1341} 1343}
1342 1344
1345static int bnx2x_remove_vlan_mac(struct bnx2x *bp,
1346 union bnx2x_qable_obj *qo,
1347 struct bnx2x_exeq_elem *elem)
1348{
1349 int rc = 0;
1350
1351 /* If consumption wasn't required, nothing to do */
1352 if (test_bit(BNX2X_DONT_CONSUME_CAM_CREDIT,
1353 &elem->cmd_data.vlan_mac.vlan_mac_flags))
1354 return 0;
1355
1356 switch (elem->cmd_data.vlan_mac.cmd) {
1357 case BNX2X_VLAN_MAC_ADD:
1358 case BNX2X_VLAN_MAC_MOVE:
1359 rc = qo->vlan_mac.put_credit(&qo->vlan_mac);
1360 break;
1361 case BNX2X_VLAN_MAC_DEL:
1362 rc = qo->vlan_mac.get_credit(&qo->vlan_mac);
1363 break;
1364 default:
1365 return -EINVAL;
1366 }
1367
1368 if (rc != true)
1369 return -EINVAL;
1370
1371 return 0;
1372}
1373
1343/** 1374/**
1344 * bnx2x_wait_vlan_mac - passivly wait for 5 seconds until all work completes. 1375 * bnx2x_wait_vlan_mac - passivly wait for 5 seconds until all work completes.
1345 * 1376 *
@@ -1801,8 +1832,14 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
1801 1832
1802 list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) { 1833 list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) {
1803 if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags == 1834 if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags ==
1804 *vlan_mac_flags) 1835 *vlan_mac_flags) {
1836 rc = exeq->remove(bp, exeq->owner, exeq_pos);
1837 if (rc) {
1838 BNX2X_ERR("Failed to remove command\n");
1839 return rc;
1840 }
1805 list_del(&exeq_pos->link); 1841 list_del(&exeq_pos->link);
1842 }
1806 } 1843 }
1807 1844
1808 spin_unlock_bh(&exeq->lock); 1845 spin_unlock_bh(&exeq->lock);
@@ -1908,6 +1945,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,
1908 bnx2x_exe_queue_init(bp, 1945 bnx2x_exe_queue_init(bp,
1909 &mac_obj->exe_queue, 1, qable_obj, 1946 &mac_obj->exe_queue, 1, qable_obj,
1910 bnx2x_validate_vlan_mac, 1947 bnx2x_validate_vlan_mac,
1948 bnx2x_remove_vlan_mac,
1911 bnx2x_optimize_vlan_mac, 1949 bnx2x_optimize_vlan_mac,
1912 bnx2x_execute_vlan_mac, 1950 bnx2x_execute_vlan_mac,
1913 bnx2x_exeq_get_mac); 1951 bnx2x_exeq_get_mac);
@@ -1924,6 +1962,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,
1924 bnx2x_exe_queue_init(bp, 1962 bnx2x_exe_queue_init(bp,
1925 &mac_obj->exe_queue, CLASSIFY_RULES_COUNT, 1963 &mac_obj->exe_queue, CLASSIFY_RULES_COUNT,
1926 qable_obj, bnx2x_validate_vlan_mac, 1964 qable_obj, bnx2x_validate_vlan_mac,
1965 bnx2x_remove_vlan_mac,
1927 bnx2x_optimize_vlan_mac, 1966 bnx2x_optimize_vlan_mac,
1928 bnx2x_execute_vlan_mac, 1967 bnx2x_execute_vlan_mac,
1929 bnx2x_exeq_get_mac); 1968 bnx2x_exeq_get_mac);
@@ -1963,6 +2002,7 @@ void bnx2x_init_vlan_obj(struct bnx2x *bp,
1963 bnx2x_exe_queue_init(bp, 2002 bnx2x_exe_queue_init(bp,
1964 &vlan_obj->exe_queue, CLASSIFY_RULES_COUNT, 2003 &vlan_obj->exe_queue, CLASSIFY_RULES_COUNT,
1965 qable_obj, bnx2x_validate_vlan_mac, 2004 qable_obj, bnx2x_validate_vlan_mac,
2005 bnx2x_remove_vlan_mac,
1966 bnx2x_optimize_vlan_mac, 2006 bnx2x_optimize_vlan_mac,
1967 bnx2x_execute_vlan_mac, 2007 bnx2x_execute_vlan_mac,
1968 bnx2x_exeq_get_vlan); 2008 bnx2x_exeq_get_vlan);
@@ -2009,6 +2049,7 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
2009 bnx2x_exe_queue_init(bp, 2049 bnx2x_exe_queue_init(bp,
2010 &vlan_mac_obj->exe_queue, 1, qable_obj, 2050 &vlan_mac_obj->exe_queue, 1, qable_obj,
2011 bnx2x_validate_vlan_mac, 2051 bnx2x_validate_vlan_mac,
2052 bnx2x_remove_vlan_mac,
2012 bnx2x_optimize_vlan_mac, 2053 bnx2x_optimize_vlan_mac,
2013 bnx2x_execute_vlan_mac, 2054 bnx2x_execute_vlan_mac,
2014 bnx2x_exeq_get_vlan_mac); 2055 bnx2x_exeq_get_vlan_mac);
@@ -2025,6 +2066,7 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
2025 &vlan_mac_obj->exe_queue, 2066 &vlan_mac_obj->exe_queue,
2026 CLASSIFY_RULES_COUNT, 2067 CLASSIFY_RULES_COUNT,
2027 qable_obj, bnx2x_validate_vlan_mac, 2068 qable_obj, bnx2x_validate_vlan_mac,
2069 bnx2x_remove_vlan_mac,
2028 bnx2x_optimize_vlan_mac, 2070 bnx2x_optimize_vlan_mac,
2029 bnx2x_execute_vlan_mac, 2071 bnx2x_execute_vlan_mac,
2030 bnx2x_exeq_get_vlan_mac); 2072 bnx2x_exeq_get_vlan_mac);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
index 992308ff82e8..66da39f0c84a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
@@ -161,6 +161,10 @@ typedef int (*exe_q_validate)(struct bnx2x *bp,
161 union bnx2x_qable_obj *o, 161 union bnx2x_qable_obj *o,
162 struct bnx2x_exeq_elem *elem); 162 struct bnx2x_exeq_elem *elem);
163 163
164typedef int (*exe_q_remove)(struct bnx2x *bp,
165 union bnx2x_qable_obj *o,
166 struct bnx2x_exeq_elem *elem);
167
164/** 168/**
165 * @return positive is entry was optimized, 0 - if not, negative 169 * @return positive is entry was optimized, 0 - if not, negative
166 * in case of an error. 170 * in case of an error.
@@ -203,11 +207,18 @@ struct bnx2x_exe_queue_obj {
203 */ 207 */
204 exe_q_validate validate; 208 exe_q_validate validate;
205 209
210 /**
211 * Called before removing pending commands, cleaning allocated
212 * resources (e.g., credits from validate)
213 */
214 exe_q_remove remove;
206 215
207 /** 216 /**
208 * This will try to cancel the current pending commands list 217 * This will try to cancel the current pending commands list
209 * considering the new command. 218 * considering the new command.
210 * 219 *
220 * Returns the number of optimized commands or a negative error code
221 *
211 * Must run under exe_queue->lock 222 * Must run under exe_queue->lock
212 */ 223 */
213 exe_q_optimize optimize; 224 exe_q_optimize optimize;