aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2013-08-27 07:27:34 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-27 15:57:05 -0400
commit7707133ceb38f590729d0165099555928630af1c (patch)
tree90ef4cfcedababd28b3df080d3fa690c66deb131 /drivers/net/ethernet/emulex
parentbea5098848925351ed6fc84dc84c88b2765237f7 (diff)
be2net: refactor be_setup() to consolidate queue creation routines
1) Move be_cmd_if_create() above queue create routines to allow TXQ creation (that requires if_handle) to be clubbed with TX-CQ creation. 2) Consolidate all queue create routines into be_setup_queues() Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c23
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c85
2 files changed, 50 insertions, 58 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 70d5db043f1e..52c9085ba5a1 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1182,25 +1182,16 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
1182 1182
1183int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo) 1183int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
1184{ 1184{
1185 struct be_mcc_wrb *wrb; 1185 struct be_mcc_wrb wrb = {0};
1186 struct be_cmd_req_eth_tx_create *req; 1186 struct be_cmd_req_eth_tx_create *req;
1187 struct be_queue_info *txq = &txo->q; 1187 struct be_queue_info *txq = &txo->q;
1188 struct be_queue_info *cq = &txo->cq; 1188 struct be_queue_info *cq = &txo->cq;
1189 struct be_dma_mem *q_mem = &txq->dma_mem; 1189 struct be_dma_mem *q_mem = &txq->dma_mem;
1190 int status, ver = 0; 1190 int status, ver = 0;
1191 1191
1192 spin_lock_bh(&adapter->mcc_lock); 1192 req = embedded_payload(&wrb);
1193
1194 wrb = wrb_from_mccq(adapter);
1195 if (!wrb) {
1196 status = -EBUSY;
1197 goto err;
1198 }
1199
1200 req = embedded_payload(wrb);
1201
1202 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, 1193 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
1203 OPCODE_ETH_TX_CREATE, sizeof(*req), wrb, NULL); 1194 OPCODE_ETH_TX_CREATE, sizeof(*req), &wrb, NULL);
1204 1195
1205 if (lancer_chip(adapter)) { 1196 if (lancer_chip(adapter)) {
1206 req->hdr.version = 1; 1197 req->hdr.version = 1;
@@ -1218,12 +1209,11 @@ int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
1218 req->cq_id = cpu_to_le16(cq->id); 1209 req->cq_id = cpu_to_le16(cq->id);
1219 req->queue_size = be_encoded_q_len(txq->len); 1210 req->queue_size = be_encoded_q_len(txq->len);
1220 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 1211 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
1221
1222 ver = req->hdr.version; 1212 ver = req->hdr.version;
1223 1213
1224 status = be_mcc_notify_wait(adapter); 1214 status = be_cmd_notify_wait(adapter, &wrb);
1225 if (!status) { 1215 if (!status) {
1226 struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); 1216 struct be_cmd_resp_eth_tx_create *resp = embedded_payload(&wrb);
1227 txq->id = le16_to_cpu(resp->cid); 1217 txq->id = le16_to_cpu(resp->cid);
1228 if (ver == 2) 1218 if (ver == 2)
1229 txo->db_offset = le32_to_cpu(resp->db_offset); 1219 txo->db_offset = le32_to_cpu(resp->db_offset);
@@ -1232,9 +1222,6 @@ int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
1232 txq->created = true; 1222 txq->created = true;
1233 } 1223 }
1234 1224
1235err:
1236 spin_unlock_bh(&adapter->mcc_lock);
1237
1238 return status; 1225 return status;
1239} 1226}
1240 1227
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index d34ea98ea2c4..b08459d268b4 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2014,7 +2014,7 @@ static void be_tx_queues_destroy(struct be_adapter *adapter)
2014 } 2014 }
2015} 2015}
2016 2016
2017static int be_tx_cqs_create(struct be_adapter *adapter) 2017static int be_tx_qs_create(struct be_adapter *adapter)
2018{ 2018{
2019 struct be_queue_info *cq, *eq; 2019 struct be_queue_info *cq, *eq;
2020 struct be_tx_obj *txo; 2020 struct be_tx_obj *txo;
@@ -2042,16 +2042,7 @@ static int be_tx_cqs_create(struct be_adapter *adapter)
2042 status = be_cmd_cq_create(adapter, cq, eq, false, 3); 2042 status = be_cmd_cq_create(adapter, cq, eq, false, 3);
2043 if (status) 2043 if (status)
2044 return status; 2044 return status;
2045 }
2046 return 0;
2047}
2048 2045
2049static int be_tx_qs_create(struct be_adapter *adapter)
2050{
2051 struct be_tx_obj *txo;
2052 int i, status;
2053
2054 for_all_tx_queues(adapter, txo, i) {
2055 status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN, 2046 status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN,
2056 sizeof(struct be_eth_wrb)); 2047 sizeof(struct be_eth_wrb));
2057 if (status) 2048 if (status)
@@ -2772,6 +2763,14 @@ done:
2772 adapter->num_vfs = 0; 2763 adapter->num_vfs = 0;
2773} 2764}
2774 2765
2766static void be_clear_queues(struct be_adapter *adapter)
2767{
2768 be_mcc_queues_destroy(adapter);
2769 be_rx_cqs_destroy(adapter);
2770 be_tx_queues_destroy(adapter);
2771 be_evt_queues_destroy(adapter);
2772}
2773
2775static int be_clear(struct be_adapter *adapter) 2774static int be_clear(struct be_adapter *adapter)
2776{ 2775{
2777 int i; 2776 int i;
@@ -2792,10 +2791,7 @@ static int be_clear(struct be_adapter *adapter)
2792 2791
2793 be_cmd_if_destroy(adapter, adapter->if_handle, 0); 2792 be_cmd_if_destroy(adapter, adapter->if_handle, 0);
2794 2793
2795 be_mcc_queues_destroy(adapter); 2794 be_clear_queues(adapter);
2796 be_rx_cqs_destroy(adapter);
2797 be_tx_queues_destroy(adapter);
2798 be_evt_queues_destroy(adapter);
2799 2795
2800 kfree(adapter->pmac_id); 2796 kfree(adapter->pmac_id);
2801 adapter->pmac_id = NULL; 2797 adapter->pmac_id = NULL;
@@ -3112,64 +3108,73 @@ static int be_mac_setup(struct be_adapter *adapter)
3112 return 0; 3108 return 0;
3113} 3109}
3114 3110
3115static int be_setup(struct be_adapter *adapter) 3111static int be_setup_queues(struct be_adapter *adapter)
3116{ 3112{
3117 struct device *dev = &adapter->pdev->dev;
3118 u32 en_flags;
3119 u32 tx_fc, rx_fc;
3120 int status; 3113 int status;
3121 3114
3122 be_setup_init(adapter); 3115 status = be_evt_queues_create(adapter);
3123
3124 if (!lancer_chip(adapter))
3125 be_cmd_req_native_mode(adapter);
3126
3127 status = be_get_config(adapter);
3128 if (status) 3116 if (status)
3129 goto err; 3117 goto err;
3130 3118
3131 status = be_msix_enable(adapter); 3119 status = be_tx_qs_create(adapter);
3132 if (status) 3120 if (status)
3133 goto err; 3121 goto err;
3134 3122
3135 status = be_evt_queues_create(adapter); 3123 status = be_rx_cqs_create(adapter);
3136 if (status) 3124 if (status)
3137 goto err; 3125 goto err;
3138 3126
3139 status = be_tx_cqs_create(adapter); 3127 status = be_mcc_queues_create(adapter);
3140 if (status) 3128 if (status)
3141 goto err; 3129 goto err;
3142 3130
3143 status = be_rx_cqs_create(adapter); 3131 return 0;
3132err:
3133 dev_err(&adapter->pdev->dev, "queue_setup failed\n");
3134 return status;
3135}
3136
3137static int be_setup(struct be_adapter *adapter)
3138{
3139 struct device *dev = &adapter->pdev->dev;
3140 u32 tx_fc, rx_fc, en_flags;
3141 int status;
3142
3143 be_setup_init(adapter);
3144
3145 if (!lancer_chip(adapter))
3146 be_cmd_req_native_mode(adapter);
3147
3148 status = be_get_config(adapter);
3144 if (status) 3149 if (status)
3145 goto err; 3150 goto err;
3146 3151
3147 status = be_mcc_queues_create(adapter); 3152 status = be_msix_enable(adapter);
3148 if (status) 3153 if (status)
3149 goto err; 3154 goto err;
3150 3155
3151 be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0);
3152 /* In UMC mode FW does not return right privileges.
3153 * Override with correct privilege equivalent to PF.
3154 */
3155 if (be_is_mc(adapter))
3156 adapter->cmd_privileges = MAX_PRIVILEGES;
3157
3158 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 3156 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
3159 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS; 3157 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
3160 if (adapter->function_caps & BE_FUNCTION_CAPS_RSS) 3158 if (adapter->function_caps & BE_FUNCTION_CAPS_RSS)
3161 en_flags |= BE_IF_FLAGS_RSS; 3159 en_flags |= BE_IF_FLAGS_RSS;
3162 en_flags = en_flags & be_if_cap_flags(adapter); 3160 en_flags = en_flags & be_if_cap_flags(adapter);
3163 status = be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags, 3161 status = be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags,
3164 &adapter->if_handle, 0); 3162 &adapter->if_handle, 0);
3165 if (status != 0) 3163 if (status)
3166 goto err; 3164 goto err;
3167 3165
3168 status = be_mac_setup(adapter); 3166 status = be_setup_queues(adapter);
3169 if (status) 3167 if (status)
3170 goto err; 3168 goto err;
3171 3169
3172 status = be_tx_qs_create(adapter); 3170 be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0);
3171 /* In UMC mode FW does not return right privileges.
3172 * Override with correct privilege equivalent to PF.
3173 */
3174 if (be_is_mc(adapter))
3175 adapter->cmd_privileges = MAX_PRIVILEGES;
3176
3177 status = be_mac_setup(adapter);
3173 if (status) 3178 if (status)
3174 goto err; 3179 goto err;
3175 3180