diff options
author | Sathya Perla <sathyap@serverengines.com> | 2009-07-27 18:52:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-02 02:06:20 -0400 |
commit | 8788fdc2a53cf012a43808877eaa6ac7e3c923b4 (patch) | |
tree | ef62e30494ee1aaced18250ddb7295ff0bb28f7a /drivers/net/benet | |
parent | 2f6d7c1b34403b97fa57473edcb6749d1db5ace3 (diff) |
be2net: get rid of be_ctrl_info struct/abstraction
Currently only the be_ctrl_info struct ptr (instead of adapter) is
passed to all the routines in be_cmds.c. Instead pass be_adapter
ptr to allow access to all its fields. Merge the contents of struct be_ctrl_info
into be_adapter. The resulting code is simpler.
Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet')
-rw-r--r-- | drivers/net/benet/be.h | 47 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.c | 293 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.h | 51 | ||||
-rw-r--r-- | drivers/net/benet/be_ethtool.c | 12 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 229 |
5 files changed, 299 insertions, 333 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index 41cddbedbf2..d8a157f8caf 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -71,6 +71,8 @@ static inline char *nic_name(struct pci_dev *pdev) | |||
71 | #define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ | 71 | #define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ |
72 | #define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST) | 72 | #define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST) |
73 | 73 | ||
74 | #define FW_VER_LEN 32 | ||
75 | |||
74 | struct be_dma_mem { | 76 | struct be_dma_mem { |
75 | void *va; | 77 | void *va; |
76 | dma_addr_t dma; | 78 | dma_addr_t dma; |
@@ -123,7 +125,6 @@ static inline void queue_tail_inc(struct be_queue_info *q) | |||
123 | index_inc(&q->tail, q->len); | 125 | index_inc(&q->tail, q->len); |
124 | } | 126 | } |
125 | 127 | ||
126 | |||
127 | struct be_eq_obj { | 128 | struct be_eq_obj { |
128 | struct be_queue_info q; | 129 | struct be_queue_info q; |
129 | char desc[32]; | 130 | char desc[32]; |
@@ -142,31 +143,6 @@ struct be_mcc_obj { | |||
142 | struct be_queue_info cq; | 143 | struct be_queue_info cq; |
143 | }; | 144 | }; |
144 | 145 | ||
145 | struct be_ctrl_info { | ||
146 | u8 __iomem *csr; | ||
147 | u8 __iomem *db; /* Door Bell */ | ||
148 | u8 __iomem *pcicfg; /* PCI config space */ | ||
149 | int pci_func; | ||
150 | |||
151 | /* Mbox used for cmd request/response */ | ||
152 | spinlock_t mbox_lock; /* For serializing mbox cmds to BE card */ | ||
153 | struct be_dma_mem mbox_mem; | ||
154 | /* Mbox mem is adjusted to align to 16 bytes. The allocated addr | ||
155 | * is stored for freeing purpose */ | ||
156 | struct be_dma_mem mbox_mem_alloced; | ||
157 | |||
158 | /* MCC Rings */ | ||
159 | struct be_mcc_obj mcc_obj; | ||
160 | spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */ | ||
161 | spinlock_t mcc_cq_lock; | ||
162 | |||
163 | /* MCC Async callback */ | ||
164 | void (*async_cb)(void *adapter, bool link_up); | ||
165 | void *adapter_ctxt; | ||
166 | }; | ||
167 | |||
168 | #include "be_cmds.h" | ||
169 | |||
170 | struct be_drvr_stats { | 146 | struct be_drvr_stats { |
171 | u32 be_tx_reqs; /* number of TX requests initiated */ | 147 | u32 be_tx_reqs; /* number of TX requests initiated */ |
172 | u32 be_tx_stops; /* number of times TX Q was stopped */ | 148 | u32 be_tx_stops; /* number of times TX Q was stopped */ |
@@ -234,8 +210,20 @@ struct be_adapter { | |||
234 | struct pci_dev *pdev; | 210 | struct pci_dev *pdev; |
235 | struct net_device *netdev; | 211 | struct net_device *netdev; |
236 | 212 | ||
237 | /* Mbox, pci config, csr address information */ | 213 | u8 __iomem *csr; |
238 | struct be_ctrl_info ctrl; | 214 | u8 __iomem *db; /* Door Bell */ |
215 | u8 __iomem *pcicfg; /* PCI config space */ | ||
216 | int pci_func; | ||
217 | |||
218 | spinlock_t mbox_lock; /* For serializing mbox cmds to BE card */ | ||
219 | struct be_dma_mem mbox_mem; | ||
220 | /* Mbox mem is adjusted to align to 16 bytes. The allocated addr | ||
221 | * is stored for freeing purpose */ | ||
222 | struct be_dma_mem mbox_mem_alloced; | ||
223 | |||
224 | struct be_mcc_obj mcc_obj; | ||
225 | spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */ | ||
226 | spinlock_t mcc_cq_lock; | ||
239 | 227 | ||
240 | struct msix_entry msix_entries[BE_NUM_MSIX_VECTORS]; | 228 | struct msix_entry msix_entries[BE_NUM_MSIX_VECTORS]; |
241 | bool msix_enabled; | 229 | bool msix_enabled; |
@@ -366,6 +354,7 @@ static inline u8 is_udp_pkt(struct sk_buff *skb) | |||
366 | return val; | 354 | return val; |
367 | } | 355 | } |
368 | 356 | ||
369 | extern void be_cq_notify(struct be_ctrl_info *ctrl, u16 qid, bool arm, | 357 | extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, |
370 | u16 num_popped); | 358 | u16 num_popped); |
359 | extern void be_link_status_update(struct be_adapter *adapter, bool link_up); | ||
371 | #endif /* BE_H */ | 360 | #endif /* BE_H */ |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 583517ed56f..20278b9d5ed 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -16,15 +16,16 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "be.h" | 18 | #include "be.h" |
19 | #include "be_cmds.h" | ||
19 | 20 | ||
20 | static void be_mcc_notify(struct be_ctrl_info *ctrl) | 21 | static void be_mcc_notify(struct be_adapter *adapter) |
21 | { | 22 | { |
22 | struct be_queue_info *mccq = &ctrl->mcc_obj.q; | 23 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
23 | u32 val = 0; | 24 | u32 val = 0; |
24 | 25 | ||
25 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; | 26 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; |
26 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; | 27 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; |
27 | iowrite32(val, ctrl->db + DB_MCCQ_OFFSET); | 28 | iowrite32(val, adapter->db + DB_MCCQ_OFFSET); |
28 | } | 29 | } |
29 | 30 | ||
30 | /* To check if valid bit is set, check the entire word as we don't know | 31 | /* To check if valid bit is set, check the entire word as we don't know |
@@ -47,7 +48,7 @@ static inline void be_mcc_compl_use(struct be_mcc_cq_entry *compl) | |||
47 | compl->flags = 0; | 48 | compl->flags = 0; |
48 | } | 49 | } |
49 | 50 | ||
50 | static int be_mcc_compl_process(struct be_ctrl_info *ctrl, | 51 | static int be_mcc_compl_process(struct be_adapter *adapter, |
51 | struct be_mcc_cq_entry *compl) | 52 | struct be_mcc_cq_entry *compl) |
52 | { | 53 | { |
53 | u16 compl_status, extd_status; | 54 | u16 compl_status, extd_status; |
@@ -70,11 +71,11 @@ static int be_mcc_compl_process(struct be_ctrl_info *ctrl, | |||
70 | } | 71 | } |
71 | 72 | ||
72 | /* Link state evt is a string of bytes; no need for endian swapping */ | 73 | /* Link state evt is a string of bytes; no need for endian swapping */ |
73 | static void be_async_link_state_process(struct be_ctrl_info *ctrl, | 74 | static void be_async_link_state_process(struct be_adapter *adapter, |
74 | struct be_async_event_link_state *evt) | 75 | struct be_async_event_link_state *evt) |
75 | { | 76 | { |
76 | ctrl->async_cb(ctrl->adapter_ctxt, | 77 | be_link_status_update(adapter, |
77 | evt->port_link_status == ASYNC_EVENT_LINK_UP ? true : false); | 78 | evt->port_link_status == ASYNC_EVENT_LINK_UP); |
78 | } | 79 | } |
79 | 80 | ||
80 | static inline bool is_link_state_evt(u32 trailer) | 81 | static inline bool is_link_state_evt(u32 trailer) |
@@ -84,9 +85,9 @@ static inline bool is_link_state_evt(u32 trailer) | |||
84 | ASYNC_EVENT_CODE_LINK_STATE); | 85 | ASYNC_EVENT_CODE_LINK_STATE); |
85 | } | 86 | } |
86 | 87 | ||
87 | static struct be_mcc_cq_entry *be_mcc_compl_get(struct be_ctrl_info *ctrl) | 88 | static struct be_mcc_cq_entry *be_mcc_compl_get(struct be_adapter *adapter) |
88 | { | 89 | { |
89 | struct be_queue_info *mcc_cq = &ctrl->mcc_obj.cq; | 90 | struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq; |
90 | struct be_mcc_cq_entry *compl = queue_tail_node(mcc_cq); | 91 | struct be_mcc_cq_entry *compl = queue_tail_node(mcc_cq); |
91 | 92 | ||
92 | if (be_mcc_compl_is_new(compl)) { | 93 | if (be_mcc_compl_is_new(compl)) { |
@@ -96,40 +97,40 @@ static struct be_mcc_cq_entry *be_mcc_compl_get(struct be_ctrl_info *ctrl) | |||
96 | return NULL; | 97 | return NULL; |
97 | } | 98 | } |
98 | 99 | ||
99 | void be_process_mcc(struct be_ctrl_info *ctrl) | 100 | void be_process_mcc(struct be_adapter *adapter) |
100 | { | 101 | { |
101 | struct be_mcc_cq_entry *compl; | 102 | struct be_mcc_cq_entry *compl; |
102 | int num = 0; | 103 | int num = 0; |
103 | 104 | ||
104 | spin_lock_bh(&ctrl->mcc_cq_lock); | 105 | spin_lock_bh(&adapter->mcc_cq_lock); |
105 | while ((compl = be_mcc_compl_get(ctrl))) { | 106 | while ((compl = be_mcc_compl_get(adapter))) { |
106 | if (compl->flags & CQE_FLAGS_ASYNC_MASK) { | 107 | if (compl->flags & CQE_FLAGS_ASYNC_MASK) { |
107 | /* Interpret flags as an async trailer */ | 108 | /* Interpret flags as an async trailer */ |
108 | BUG_ON(!is_link_state_evt(compl->flags)); | 109 | BUG_ON(!is_link_state_evt(compl->flags)); |
109 | 110 | ||
110 | /* Interpret compl as a async link evt */ | 111 | /* Interpret compl as a async link evt */ |
111 | be_async_link_state_process(ctrl, | 112 | be_async_link_state_process(adapter, |
112 | (struct be_async_event_link_state *) compl); | 113 | (struct be_async_event_link_state *) compl); |
113 | } else { | 114 | } else { |
114 | be_mcc_compl_process(ctrl, compl); | 115 | be_mcc_compl_process(adapter, compl); |
115 | atomic_dec(&ctrl->mcc_obj.q.used); | 116 | atomic_dec(&adapter->mcc_obj.q.used); |
116 | } | 117 | } |
117 | be_mcc_compl_use(compl); | 118 | be_mcc_compl_use(compl); |
118 | num++; | 119 | num++; |
119 | } | 120 | } |
120 | if (num) | 121 | if (num) |
121 | be_cq_notify(ctrl, ctrl->mcc_obj.cq.id, true, num); | 122 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num); |
122 | spin_unlock_bh(&ctrl->mcc_cq_lock); | 123 | spin_unlock_bh(&adapter->mcc_cq_lock); |
123 | } | 124 | } |
124 | 125 | ||
125 | /* Wait till no more pending mcc requests are present */ | 126 | /* Wait till no more pending mcc requests are present */ |
126 | static void be_mcc_wait_compl(struct be_ctrl_info *ctrl) | 127 | static void be_mcc_wait_compl(struct be_adapter *adapter) |
127 | { | 128 | { |
128 | #define mcc_timeout 50000 /* 5s timeout */ | 129 | #define mcc_timeout 50000 /* 5s timeout */ |
129 | int i; | 130 | int i; |
130 | for (i = 0; i < mcc_timeout; i++) { | 131 | for (i = 0; i < mcc_timeout; i++) { |
131 | be_process_mcc(ctrl); | 132 | be_process_mcc(adapter); |
132 | if (atomic_read(&ctrl->mcc_obj.q.used) == 0) | 133 | if (atomic_read(&adapter->mcc_obj.q.used) == 0) |
133 | break; | 134 | break; |
134 | udelay(100); | 135 | udelay(100); |
135 | } | 136 | } |
@@ -138,10 +139,10 @@ static void be_mcc_wait_compl(struct be_ctrl_info *ctrl) | |||
138 | } | 139 | } |
139 | 140 | ||
140 | /* Notify MCC requests and wait for completion */ | 141 | /* Notify MCC requests and wait for completion */ |
141 | static void be_mcc_notify_wait(struct be_ctrl_info *ctrl) | 142 | static void be_mcc_notify_wait(struct be_adapter *adapter) |
142 | { | 143 | { |
143 | be_mcc_notify(ctrl); | 144 | be_mcc_notify(adapter); |
144 | be_mcc_wait_compl(ctrl); | 145 | be_mcc_wait_compl(adapter); |
145 | } | 146 | } |
146 | 147 | ||
147 | static int be_mbox_db_ready_wait(void __iomem *db) | 148 | static int be_mbox_db_ready_wait(void __iomem *db) |
@@ -173,12 +174,12 @@ static int be_mbox_db_ready_wait(void __iomem *db) | |||
173 | * Insert the mailbox address into the doorbell in two steps | 174 | * Insert the mailbox address into the doorbell in two steps |
174 | * Polls on the mbox doorbell till a command completion (or a timeout) occurs | 175 | * Polls on the mbox doorbell till a command completion (or a timeout) occurs |
175 | */ | 176 | */ |
176 | static int be_mbox_db_ring(struct be_ctrl_info *ctrl) | 177 | static int be_mbox_db_ring(struct be_adapter *adapter) |
177 | { | 178 | { |
178 | int status; | 179 | int status; |
179 | u32 val = 0; | 180 | u32 val = 0; |
180 | void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET; | 181 | void __iomem *db = adapter->db + MPU_MAILBOX_DB_OFFSET; |
181 | struct be_dma_mem *mbox_mem = &ctrl->mbox_mem; | 182 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
182 | struct be_mcc_mailbox *mbox = mbox_mem->va; | 183 | struct be_mcc_mailbox *mbox = mbox_mem->va; |
183 | struct be_mcc_cq_entry *cqe = &mbox->cqe; | 184 | struct be_mcc_cq_entry *cqe = &mbox->cqe; |
184 | 185 | ||
@@ -208,7 +209,7 @@ static int be_mbox_db_ring(struct be_ctrl_info *ctrl) | |||
208 | 209 | ||
209 | /* A cq entry has been made now */ | 210 | /* A cq entry has been made now */ |
210 | if (be_mcc_compl_is_new(cqe)) { | 211 | if (be_mcc_compl_is_new(cqe)) { |
211 | status = be_mcc_compl_process(ctrl, &mbox->cqe); | 212 | status = be_mcc_compl_process(adapter, &mbox->cqe); |
212 | be_mcc_compl_use(cqe); | 213 | be_mcc_compl_use(cqe); |
213 | if (status) | 214 | if (status) |
214 | return status; | 215 | return status; |
@@ -219,9 +220,9 @@ static int be_mbox_db_ring(struct be_ctrl_info *ctrl) | |||
219 | return 0; | 220 | return 0; |
220 | } | 221 | } |
221 | 222 | ||
222 | static int be_POST_stage_get(struct be_ctrl_info *ctrl, u16 *stage) | 223 | static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage) |
223 | { | 224 | { |
224 | u32 sem = ioread32(ctrl->csr + MPU_EP_SEMAPHORE_OFFSET); | 225 | u32 sem = ioread32(adapter->csr + MPU_EP_SEMAPHORE_OFFSET); |
225 | 226 | ||
226 | *stage = sem & EP_SEMAPHORE_POST_STAGE_MASK; | 227 | *stage = sem & EP_SEMAPHORE_POST_STAGE_MASK; |
227 | if ((sem >> EP_SEMAPHORE_POST_ERR_SHIFT) & EP_SEMAPHORE_POST_ERR_MASK) | 228 | if ((sem >> EP_SEMAPHORE_POST_ERR_SHIFT) & EP_SEMAPHORE_POST_ERR_MASK) |
@@ -230,11 +231,11 @@ static int be_POST_stage_get(struct be_ctrl_info *ctrl, u16 *stage) | |||
230 | return 0; | 231 | return 0; |
231 | } | 232 | } |
232 | 233 | ||
233 | static int be_POST_stage_poll(struct be_ctrl_info *ctrl, u16 poll_stage) | 234 | static int be_POST_stage_poll(struct be_adapter *adapter, u16 poll_stage) |
234 | { | 235 | { |
235 | u16 stage, cnt, error; | 236 | u16 stage, cnt, error; |
236 | for (cnt = 0; cnt < 5000; cnt++) { | 237 | for (cnt = 0; cnt < 5000; cnt++) { |
237 | error = be_POST_stage_get(ctrl, &stage); | 238 | error = be_POST_stage_get(adapter, &stage); |
238 | if (error) | 239 | if (error) |
239 | return -1; | 240 | return -1; |
240 | 241 | ||
@@ -248,11 +249,11 @@ static int be_POST_stage_poll(struct be_ctrl_info *ctrl, u16 poll_stage) | |||
248 | } | 249 | } |
249 | 250 | ||
250 | 251 | ||
251 | int be_cmd_POST(struct be_ctrl_info *ctrl) | 252 | int be_cmd_POST(struct be_adapter *adapter) |
252 | { | 253 | { |
253 | u16 stage, error; | 254 | u16 stage, error; |
254 | 255 | ||
255 | error = be_POST_stage_get(ctrl, &stage); | 256 | error = be_POST_stage_get(adapter, &stage); |
256 | if (error) | 257 | if (error) |
257 | goto err; | 258 | goto err; |
258 | 259 | ||
@@ -263,14 +264,14 @@ int be_cmd_POST(struct be_ctrl_info *ctrl) | |||
263 | goto err; | 264 | goto err; |
264 | 265 | ||
265 | /* On awaiting host rdy, reset and again poll on awaiting host rdy */ | 266 | /* On awaiting host rdy, reset and again poll on awaiting host rdy */ |
266 | iowrite32(POST_STAGE_BE_RESET, ctrl->csr + MPU_EP_SEMAPHORE_OFFSET); | 267 | iowrite32(POST_STAGE_BE_RESET, adapter->csr + MPU_EP_SEMAPHORE_OFFSET); |
267 | error = be_POST_stage_poll(ctrl, POST_STAGE_AWAITING_HOST_RDY); | 268 | error = be_POST_stage_poll(adapter, POST_STAGE_AWAITING_HOST_RDY); |
268 | if (error) | 269 | if (error) |
269 | goto err; | 270 | goto err; |
270 | 271 | ||
271 | /* Now kickoff POST and poll on armfw ready */ | 272 | /* Now kickoff POST and poll on armfw ready */ |
272 | iowrite32(POST_STAGE_HOST_RDY, ctrl->csr + MPU_EP_SEMAPHORE_OFFSET); | 273 | iowrite32(POST_STAGE_HOST_RDY, adapter->csr + MPU_EP_SEMAPHORE_OFFSET); |
273 | error = be_POST_stage_poll(ctrl, POST_STAGE_ARMFW_RDY); | 274 | error = be_POST_stage_poll(adapter, POST_STAGE_ARMFW_RDY); |
274 | if (error) | 275 | if (error) |
275 | goto err; | 276 | goto err; |
276 | 277 | ||
@@ -367,16 +368,16 @@ static inline struct be_mcc_wrb *wrb_from_mcc(struct be_queue_info *mccq) | |||
367 | return wrb; | 368 | return wrb; |
368 | } | 369 | } |
369 | 370 | ||
370 | int be_cmd_eq_create(struct be_ctrl_info *ctrl, | 371 | int be_cmd_eq_create(struct be_adapter *adapter, |
371 | struct be_queue_info *eq, int eq_delay) | 372 | struct be_queue_info *eq, int eq_delay) |
372 | { | 373 | { |
373 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 374 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
374 | struct be_cmd_req_eq_create *req = embedded_payload(wrb); | 375 | struct be_cmd_req_eq_create *req = embedded_payload(wrb); |
375 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); | 376 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); |
376 | struct be_dma_mem *q_mem = &eq->dma_mem; | 377 | struct be_dma_mem *q_mem = &eq->dma_mem; |
377 | int status; | 378 | int status; |
378 | 379 | ||
379 | spin_lock(&ctrl->mbox_lock); | 380 | spin_lock(&adapter->mbox_lock); |
380 | memset(wrb, 0, sizeof(*wrb)); | 381 | memset(wrb, 0, sizeof(*wrb)); |
381 | 382 | ||
382 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 383 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -387,7 +388,7 @@ int be_cmd_eq_create(struct be_ctrl_info *ctrl, | |||
387 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); | 388 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
388 | 389 | ||
389 | AMAP_SET_BITS(struct amap_eq_context, func, req->context, | 390 | AMAP_SET_BITS(struct amap_eq_context, func, req->context, |
390 | ctrl->pci_func); | 391 | adapter->pci_func); |
391 | AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); | 392 | AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); |
392 | /* 4byte eqe*/ | 393 | /* 4byte eqe*/ |
393 | AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); | 394 | AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); |
@@ -399,24 +400,24 @@ int be_cmd_eq_create(struct be_ctrl_info *ctrl, | |||
399 | 400 | ||
400 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 401 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
401 | 402 | ||
402 | status = be_mbox_db_ring(ctrl); | 403 | status = be_mbox_db_ring(adapter); |
403 | if (!status) { | 404 | if (!status) { |
404 | eq->id = le16_to_cpu(resp->eq_id); | 405 | eq->id = le16_to_cpu(resp->eq_id); |
405 | eq->created = true; | 406 | eq->created = true; |
406 | } | 407 | } |
407 | spin_unlock(&ctrl->mbox_lock); | 408 | spin_unlock(&adapter->mbox_lock); |
408 | return status; | 409 | return status; |
409 | } | 410 | } |
410 | 411 | ||
411 | int be_cmd_mac_addr_query(struct be_ctrl_info *ctrl, u8 *mac_addr, | 412 | int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, |
412 | u8 type, bool permanent, u32 if_handle) | 413 | u8 type, bool permanent, u32 if_handle) |
413 | { | 414 | { |
414 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 415 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
415 | struct be_cmd_req_mac_query *req = embedded_payload(wrb); | 416 | struct be_cmd_req_mac_query *req = embedded_payload(wrb); |
416 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); | 417 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); |
417 | int status; | 418 | int status; |
418 | 419 | ||
419 | spin_lock(&ctrl->mbox_lock); | 420 | spin_lock(&adapter->mbox_lock); |
420 | memset(wrb, 0, sizeof(*wrb)); | 421 | memset(wrb, 0, sizeof(*wrb)); |
421 | 422 | ||
422 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 423 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -432,22 +433,22 @@ int be_cmd_mac_addr_query(struct be_ctrl_info *ctrl, u8 *mac_addr, | |||
432 | req->permanent = 0; | 433 | req->permanent = 0; |
433 | } | 434 | } |
434 | 435 | ||
435 | status = be_mbox_db_ring(ctrl); | 436 | status = be_mbox_db_ring(adapter); |
436 | if (!status) | 437 | if (!status) |
437 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); | 438 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); |
438 | 439 | ||
439 | spin_unlock(&ctrl->mbox_lock); | 440 | spin_unlock(&adapter->mbox_lock); |
440 | return status; | 441 | return status; |
441 | } | 442 | } |
442 | 443 | ||
443 | int be_cmd_pmac_add(struct be_ctrl_info *ctrl, u8 *mac_addr, | 444 | int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
444 | u32 if_id, u32 *pmac_id) | 445 | u32 if_id, u32 *pmac_id) |
445 | { | 446 | { |
446 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 447 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
447 | struct be_cmd_req_pmac_add *req = embedded_payload(wrb); | 448 | struct be_cmd_req_pmac_add *req = embedded_payload(wrb); |
448 | int status; | 449 | int status; |
449 | 450 | ||
450 | spin_lock(&ctrl->mbox_lock); | 451 | spin_lock(&adapter->mbox_lock); |
451 | memset(wrb, 0, sizeof(*wrb)); | 452 | memset(wrb, 0, sizeof(*wrb)); |
452 | 453 | ||
453 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 454 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -458,23 +459,23 @@ int be_cmd_pmac_add(struct be_ctrl_info *ctrl, u8 *mac_addr, | |||
458 | req->if_id = cpu_to_le32(if_id); | 459 | req->if_id = cpu_to_le32(if_id); |
459 | memcpy(req->mac_address, mac_addr, ETH_ALEN); | 460 | memcpy(req->mac_address, mac_addr, ETH_ALEN); |
460 | 461 | ||
461 | status = be_mbox_db_ring(ctrl); | 462 | status = be_mbox_db_ring(adapter); |
462 | if (!status) { | 463 | if (!status) { |
463 | struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); | 464 | struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); |
464 | *pmac_id = le32_to_cpu(resp->pmac_id); | 465 | *pmac_id = le32_to_cpu(resp->pmac_id); |
465 | } | 466 | } |
466 | 467 | ||
467 | spin_unlock(&ctrl->mbox_lock); | 468 | spin_unlock(&adapter->mbox_lock); |
468 | return status; | 469 | return status; |
469 | } | 470 | } |
470 | 471 | ||
471 | int be_cmd_pmac_del(struct be_ctrl_info *ctrl, u32 if_id, u32 pmac_id) | 472 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id) |
472 | { | 473 | { |
473 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 474 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
474 | struct be_cmd_req_pmac_del *req = embedded_payload(wrb); | 475 | struct be_cmd_req_pmac_del *req = embedded_payload(wrb); |
475 | int status; | 476 | int status; |
476 | 477 | ||
477 | spin_lock(&ctrl->mbox_lock); | 478 | spin_lock(&adapter->mbox_lock); |
478 | memset(wrb, 0, sizeof(*wrb)); | 479 | memset(wrb, 0, sizeof(*wrb)); |
479 | 480 | ||
480 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 481 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -485,24 +486,24 @@ int be_cmd_pmac_del(struct be_ctrl_info *ctrl, u32 if_id, u32 pmac_id) | |||
485 | req->if_id = cpu_to_le32(if_id); | 486 | req->if_id = cpu_to_le32(if_id); |
486 | req->pmac_id = cpu_to_le32(pmac_id); | 487 | req->pmac_id = cpu_to_le32(pmac_id); |
487 | 488 | ||
488 | status = be_mbox_db_ring(ctrl); | 489 | status = be_mbox_db_ring(adapter); |
489 | spin_unlock(&ctrl->mbox_lock); | 490 | spin_unlock(&adapter->mbox_lock); |
490 | 491 | ||
491 | return status; | 492 | return status; |
492 | } | 493 | } |
493 | 494 | ||
494 | int be_cmd_cq_create(struct be_ctrl_info *ctrl, | 495 | int be_cmd_cq_create(struct be_adapter *adapter, |
495 | struct be_queue_info *cq, struct be_queue_info *eq, | 496 | struct be_queue_info *cq, struct be_queue_info *eq, |
496 | bool sol_evts, bool no_delay, int coalesce_wm) | 497 | bool sol_evts, bool no_delay, int coalesce_wm) |
497 | { | 498 | { |
498 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 499 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
499 | struct be_cmd_req_cq_create *req = embedded_payload(wrb); | 500 | struct be_cmd_req_cq_create *req = embedded_payload(wrb); |
500 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); | 501 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); |
501 | struct be_dma_mem *q_mem = &cq->dma_mem; | 502 | struct be_dma_mem *q_mem = &cq->dma_mem; |
502 | void *ctxt = &req->context; | 503 | void *ctxt = &req->context; |
503 | int status; | 504 | int status; |
504 | 505 | ||
505 | spin_lock(&ctrl->mbox_lock); | 506 | spin_lock(&adapter->mbox_lock); |
506 | memset(wrb, 0, sizeof(*wrb)); | 507 | memset(wrb, 0, sizeof(*wrb)); |
507 | 508 | ||
508 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 509 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -521,17 +522,17 @@ int be_cmd_cq_create(struct be_ctrl_info *ctrl, | |||
521 | AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1); | 522 | AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1); |
522 | AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); | 523 | AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); |
523 | AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); | 524 | AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); |
524 | AMAP_SET_BITS(struct amap_cq_context, func, ctxt, ctrl->pci_func); | 525 | AMAP_SET_BITS(struct amap_cq_context, func, ctxt, adapter->pci_func); |
525 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); | 526 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
526 | 527 | ||
527 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 528 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
528 | 529 | ||
529 | status = be_mbox_db_ring(ctrl); | 530 | status = be_mbox_db_ring(adapter); |
530 | if (!status) { | 531 | if (!status) { |
531 | cq->id = le16_to_cpu(resp->cq_id); | 532 | cq->id = le16_to_cpu(resp->cq_id); |
532 | cq->created = true; | 533 | cq->created = true; |
533 | } | 534 | } |
534 | spin_unlock(&ctrl->mbox_lock); | 535 | spin_unlock(&adapter->mbox_lock); |
535 | 536 | ||
536 | return status; | 537 | return status; |
537 | } | 538 | } |
@@ -544,17 +545,17 @@ static u32 be_encoded_q_len(int q_len) | |||
544 | return len_encoded; | 545 | return len_encoded; |
545 | } | 546 | } |
546 | 547 | ||
547 | int be_cmd_mccq_create(struct be_ctrl_info *ctrl, | 548 | int be_cmd_mccq_create(struct be_adapter *adapter, |
548 | struct be_queue_info *mccq, | 549 | struct be_queue_info *mccq, |
549 | struct be_queue_info *cq) | 550 | struct be_queue_info *cq) |
550 | { | 551 | { |
551 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 552 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
552 | struct be_cmd_req_mcc_create *req = embedded_payload(wrb); | 553 | struct be_cmd_req_mcc_create *req = embedded_payload(wrb); |
553 | struct be_dma_mem *q_mem = &mccq->dma_mem; | 554 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
554 | void *ctxt = &req->context; | 555 | void *ctxt = &req->context; |
555 | int status; | 556 | int status; |
556 | 557 | ||
557 | spin_lock(&ctrl->mbox_lock); | 558 | spin_lock(&adapter->mbox_lock); |
558 | memset(wrb, 0, sizeof(*wrb)); | 559 | memset(wrb, 0, sizeof(*wrb)); |
559 | 560 | ||
560 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 561 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -564,7 +565,7 @@ int be_cmd_mccq_create(struct be_ctrl_info *ctrl, | |||
564 | 565 | ||
565 | req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); | 566 | req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); |
566 | 567 | ||
567 | AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt, ctrl->pci_func); | 568 | AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt, adapter->pci_func); |
568 | AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1); | 569 | AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1); |
569 | AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt, | 570 | AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt, |
570 | be_encoded_q_len(mccq->len)); | 571 | be_encoded_q_len(mccq->len)); |
@@ -574,29 +575,29 @@ int be_cmd_mccq_create(struct be_ctrl_info *ctrl, | |||
574 | 575 | ||
575 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 576 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
576 | 577 | ||
577 | status = be_mbox_db_ring(ctrl); | 578 | status = be_mbox_db_ring(adapter); |
578 | if (!status) { | 579 | if (!status) { |
579 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); | 580 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); |
580 | mccq->id = le16_to_cpu(resp->id); | 581 | mccq->id = le16_to_cpu(resp->id); |
581 | mccq->created = true; | 582 | mccq->created = true; |
582 | } | 583 | } |
583 | spin_unlock(&ctrl->mbox_lock); | 584 | spin_unlock(&adapter->mbox_lock); |
584 | 585 | ||
585 | return status; | 586 | return status; |
586 | } | 587 | } |
587 | 588 | ||
588 | int be_cmd_txq_create(struct be_ctrl_info *ctrl, | 589 | int be_cmd_txq_create(struct be_adapter *adapter, |
589 | struct be_queue_info *txq, | 590 | struct be_queue_info *txq, |
590 | struct be_queue_info *cq) | 591 | struct be_queue_info *cq) |
591 | { | 592 | { |
592 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 593 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
593 | struct be_cmd_req_eth_tx_create *req = embedded_payload(wrb); | 594 | struct be_cmd_req_eth_tx_create *req = embedded_payload(wrb); |
594 | struct be_dma_mem *q_mem = &txq->dma_mem; | 595 | struct be_dma_mem *q_mem = &txq->dma_mem; |
595 | void *ctxt = &req->context; | 596 | void *ctxt = &req->context; |
596 | int status; | 597 | int status; |
597 | u32 len_encoded; | 598 | u32 len_encoded; |
598 | 599 | ||
599 | spin_lock(&ctrl->mbox_lock); | 600 | spin_lock(&adapter->mbox_lock); |
600 | memset(wrb, 0, sizeof(*wrb)); | 601 | memset(wrb, 0, sizeof(*wrb)); |
601 | 602 | ||
602 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 603 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -613,7 +614,7 @@ int be_cmd_txq_create(struct be_ctrl_info *ctrl, | |||
613 | len_encoded = 0; | 614 | len_encoded = 0; |
614 | AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, len_encoded); | 615 | AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, len_encoded); |
615 | AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt, | 616 | AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt, |
616 | ctrl->pci_func); | 617 | adapter->pci_func); |
617 | AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); | 618 | AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); |
618 | AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id); | 619 | AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id); |
619 | 620 | ||
@@ -621,27 +622,27 @@ int be_cmd_txq_create(struct be_ctrl_info *ctrl, | |||
621 | 622 | ||
622 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 623 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
623 | 624 | ||
624 | status = be_mbox_db_ring(ctrl); | 625 | status = be_mbox_db_ring(adapter); |
625 | if (!status) { | 626 | if (!status) { |
626 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); | 627 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); |
627 | txq->id = le16_to_cpu(resp->cid); | 628 | txq->id = le16_to_cpu(resp->cid); |
628 | txq->created = true; | 629 | txq->created = true; |
629 | } | 630 | } |
630 | spin_unlock(&ctrl->mbox_lock); | 631 | spin_unlock(&adapter->mbox_lock); |
631 | 632 | ||
632 | return status; | 633 | return status; |
633 | } | 634 | } |
634 | 635 | ||
635 | int be_cmd_rxq_create(struct be_ctrl_info *ctrl, | 636 | int be_cmd_rxq_create(struct be_adapter *adapter, |
636 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, | 637 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, |
637 | u16 max_frame_size, u32 if_id, u32 rss) | 638 | u16 max_frame_size, u32 if_id, u32 rss) |
638 | { | 639 | { |
639 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 640 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
640 | struct be_cmd_req_eth_rx_create *req = embedded_payload(wrb); | 641 | struct be_cmd_req_eth_rx_create *req = embedded_payload(wrb); |
641 | struct be_dma_mem *q_mem = &rxq->dma_mem; | 642 | struct be_dma_mem *q_mem = &rxq->dma_mem; |
642 | int status; | 643 | int status; |
643 | 644 | ||
644 | spin_lock(&ctrl->mbox_lock); | 645 | spin_lock(&adapter->mbox_lock); |
645 | memset(wrb, 0, sizeof(*wrb)); | 646 | memset(wrb, 0, sizeof(*wrb)); |
646 | 647 | ||
647 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 648 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -657,27 +658,27 @@ int be_cmd_rxq_create(struct be_ctrl_info *ctrl, | |||
657 | req->max_frame_size = cpu_to_le16(max_frame_size); | 658 | req->max_frame_size = cpu_to_le16(max_frame_size); |
658 | req->rss_queue = cpu_to_le32(rss); | 659 | req->rss_queue = cpu_to_le32(rss); |
659 | 660 | ||
660 | status = be_mbox_db_ring(ctrl); | 661 | status = be_mbox_db_ring(adapter); |
661 | if (!status) { | 662 | if (!status) { |
662 | struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); | 663 | struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); |
663 | rxq->id = le16_to_cpu(resp->id); | 664 | rxq->id = le16_to_cpu(resp->id); |
664 | rxq->created = true; | 665 | rxq->created = true; |
665 | } | 666 | } |
666 | spin_unlock(&ctrl->mbox_lock); | 667 | spin_unlock(&adapter->mbox_lock); |
667 | 668 | ||
668 | return status; | 669 | return status; |
669 | } | 670 | } |
670 | 671 | ||
671 | /* Generic destroyer function for all types of queues */ | 672 | /* Generic destroyer function for all types of queues */ |
672 | int be_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, | 673 | int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, |
673 | int queue_type) | 674 | int queue_type) |
674 | { | 675 | { |
675 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 676 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
676 | struct be_cmd_req_q_destroy *req = embedded_payload(wrb); | 677 | struct be_cmd_req_q_destroy *req = embedded_payload(wrb); |
677 | u8 subsys = 0, opcode = 0; | 678 | u8 subsys = 0, opcode = 0; |
678 | int status; | 679 | int status; |
679 | 680 | ||
680 | spin_lock(&ctrl->mbox_lock); | 681 | spin_lock(&adapter->mbox_lock); |
681 | 682 | ||
682 | memset(wrb, 0, sizeof(*wrb)); | 683 | memset(wrb, 0, sizeof(*wrb)); |
683 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 684 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -711,22 +712,22 @@ int be_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, | |||
711 | be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); | 712 | be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); |
712 | req->id = cpu_to_le16(q->id); | 713 | req->id = cpu_to_le16(q->id); |
713 | 714 | ||
714 | status = be_mbox_db_ring(ctrl); | 715 | status = be_mbox_db_ring(adapter); |
715 | err: | 716 | err: |
716 | spin_unlock(&ctrl->mbox_lock); | 717 | spin_unlock(&adapter->mbox_lock); |
717 | 718 | ||
718 | return status; | 719 | return status; |
719 | } | 720 | } |
720 | 721 | ||
721 | /* Create an rx filtering policy configuration on an i/f */ | 722 | /* Create an rx filtering policy configuration on an i/f */ |
722 | int be_cmd_if_create(struct be_ctrl_info *ctrl, u32 flags, u8 *mac, | 723 | int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, |
723 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id) | 724 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id) |
724 | { | 725 | { |
725 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 726 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
726 | struct be_cmd_req_if_create *req = embedded_payload(wrb); | 727 | struct be_cmd_req_if_create *req = embedded_payload(wrb); |
727 | int status; | 728 | int status; |
728 | 729 | ||
729 | spin_lock(&ctrl->mbox_lock); | 730 | spin_lock(&adapter->mbox_lock); |
730 | memset(wrb, 0, sizeof(*wrb)); | 731 | memset(wrb, 0, sizeof(*wrb)); |
731 | 732 | ||
732 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 733 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -739,7 +740,7 @@ int be_cmd_if_create(struct be_ctrl_info *ctrl, u32 flags, u8 *mac, | |||
739 | if (!pmac_invalid) | 740 | if (!pmac_invalid) |
740 | memcpy(req->mac_addr, mac, ETH_ALEN); | 741 | memcpy(req->mac_addr, mac, ETH_ALEN); |
741 | 742 | ||
742 | status = be_mbox_db_ring(ctrl); | 743 | status = be_mbox_db_ring(adapter); |
743 | if (!status) { | 744 | if (!status) { |
744 | struct be_cmd_resp_if_create *resp = embedded_payload(wrb); | 745 | struct be_cmd_resp_if_create *resp = embedded_payload(wrb); |
745 | *if_handle = le32_to_cpu(resp->interface_id); | 746 | *if_handle = le32_to_cpu(resp->interface_id); |
@@ -747,17 +748,17 @@ int be_cmd_if_create(struct be_ctrl_info *ctrl, u32 flags, u8 *mac, | |||
747 | *pmac_id = le32_to_cpu(resp->pmac_id); | 748 | *pmac_id = le32_to_cpu(resp->pmac_id); |
748 | } | 749 | } |
749 | 750 | ||
750 | spin_unlock(&ctrl->mbox_lock); | 751 | spin_unlock(&adapter->mbox_lock); |
751 | return status; | 752 | return status; |
752 | } | 753 | } |
753 | 754 | ||
754 | int be_cmd_if_destroy(struct be_ctrl_info *ctrl, u32 interface_id) | 755 | int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) |
755 | { | 756 | { |
756 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 757 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
757 | struct be_cmd_req_if_destroy *req = embedded_payload(wrb); | 758 | struct be_cmd_req_if_destroy *req = embedded_payload(wrb); |
758 | int status; | 759 | int status; |
759 | 760 | ||
760 | spin_lock(&ctrl->mbox_lock); | 761 | spin_lock(&adapter->mbox_lock); |
761 | memset(wrb, 0, sizeof(*wrb)); | 762 | memset(wrb, 0, sizeof(*wrb)); |
762 | 763 | ||
763 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 764 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -766,9 +767,9 @@ int be_cmd_if_destroy(struct be_ctrl_info *ctrl, u32 interface_id) | |||
766 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req)); | 767 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req)); |
767 | 768 | ||
768 | req->interface_id = cpu_to_le32(interface_id); | 769 | req->interface_id = cpu_to_le32(interface_id); |
769 | status = be_mbox_db_ring(ctrl); | 770 | status = be_mbox_db_ring(adapter); |
770 | 771 | ||
771 | spin_unlock(&ctrl->mbox_lock); | 772 | spin_unlock(&adapter->mbox_lock); |
772 | 773 | ||
773 | return status; | 774 | return status; |
774 | } | 775 | } |
@@ -776,14 +777,14 @@ int be_cmd_if_destroy(struct be_ctrl_info *ctrl, u32 interface_id) | |||
776 | /* Get stats is a non embedded command: the request is not embedded inside | 777 | /* Get stats is a non embedded command: the request is not embedded inside |
777 | * WRB but is a separate dma memory block | 778 | * WRB but is a separate dma memory block |
778 | */ | 779 | */ |
779 | int be_cmd_get_stats(struct be_ctrl_info *ctrl, struct be_dma_mem *nonemb_cmd) | 780 | int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) |
780 | { | 781 | { |
781 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 782 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
782 | struct be_cmd_req_get_stats *req = nonemb_cmd->va; | 783 | struct be_cmd_req_get_stats *req = nonemb_cmd->va; |
783 | struct be_sge *sge = nonembedded_sgl(wrb); | 784 | struct be_sge *sge = nonembedded_sgl(wrb); |
784 | int status; | 785 | int status; |
785 | 786 | ||
786 | spin_lock(&ctrl->mbox_lock); | 787 | spin_lock(&adapter->mbox_lock); |
787 | memset(wrb, 0, sizeof(*wrb)); | 788 | memset(wrb, 0, sizeof(*wrb)); |
788 | 789 | ||
789 | memset(req, 0, sizeof(*req)); | 790 | memset(req, 0, sizeof(*req)); |
@@ -796,24 +797,24 @@ int be_cmd_get_stats(struct be_ctrl_info *ctrl, struct be_dma_mem *nonemb_cmd) | |||
796 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); | 797 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
797 | sge->len = cpu_to_le32(nonemb_cmd->size); | 798 | sge->len = cpu_to_le32(nonemb_cmd->size); |
798 | 799 | ||
799 | status = be_mbox_db_ring(ctrl); | 800 | status = be_mbox_db_ring(adapter); |
800 | if (!status) { | 801 | if (!status) { |
801 | struct be_cmd_resp_get_stats *resp = nonemb_cmd->va; | 802 | struct be_cmd_resp_get_stats *resp = nonemb_cmd->va; |
802 | be_dws_le_to_cpu(&resp->hw_stats, sizeof(resp->hw_stats)); | 803 | be_dws_le_to_cpu(&resp->hw_stats, sizeof(resp->hw_stats)); |
803 | } | 804 | } |
804 | 805 | ||
805 | spin_unlock(&ctrl->mbox_lock); | 806 | spin_unlock(&adapter->mbox_lock); |
806 | return status; | 807 | return status; |
807 | } | 808 | } |
808 | 809 | ||
809 | int be_cmd_link_status_query(struct be_ctrl_info *ctrl, | 810 | int be_cmd_link_status_query(struct be_adapter *adapter, |
810 | bool *link_up) | 811 | bool *link_up) |
811 | { | 812 | { |
812 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 813 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
813 | struct be_cmd_req_link_status *req = embedded_payload(wrb); | 814 | struct be_cmd_req_link_status *req = embedded_payload(wrb); |
814 | int status; | 815 | int status; |
815 | 816 | ||
816 | spin_lock(&ctrl->mbox_lock); | 817 | spin_lock(&adapter->mbox_lock); |
817 | 818 | ||
818 | *link_up = false; | 819 | *link_up = false; |
819 | memset(wrb, 0, sizeof(*wrb)); | 820 | memset(wrb, 0, sizeof(*wrb)); |
@@ -823,24 +824,24 @@ int be_cmd_link_status_query(struct be_ctrl_info *ctrl, | |||
823 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 824 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
824 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req)); | 825 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req)); |
825 | 826 | ||
826 | status = be_mbox_db_ring(ctrl); | 827 | status = be_mbox_db_ring(adapter); |
827 | if (!status) { | 828 | if (!status) { |
828 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); | 829 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); |
829 | if (resp->mac_speed != PHY_LINK_SPEED_ZERO) | 830 | if (resp->mac_speed != PHY_LINK_SPEED_ZERO) |
830 | *link_up = true; | 831 | *link_up = true; |
831 | } | 832 | } |
832 | 833 | ||
833 | spin_unlock(&ctrl->mbox_lock); | 834 | spin_unlock(&adapter->mbox_lock); |
834 | return status; | 835 | return status; |
835 | } | 836 | } |
836 | 837 | ||
837 | int be_cmd_get_fw_ver(struct be_ctrl_info *ctrl, char *fw_ver) | 838 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) |
838 | { | 839 | { |
839 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 840 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
840 | struct be_cmd_req_get_fw_version *req = embedded_payload(wrb); | 841 | struct be_cmd_req_get_fw_version *req = embedded_payload(wrb); |
841 | int status; | 842 | int status; |
842 | 843 | ||
843 | spin_lock(&ctrl->mbox_lock); | 844 | spin_lock(&adapter->mbox_lock); |
844 | memset(wrb, 0, sizeof(*wrb)); | 845 | memset(wrb, 0, sizeof(*wrb)); |
845 | 846 | ||
846 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 847 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -848,24 +849,24 @@ int be_cmd_get_fw_ver(struct be_ctrl_info *ctrl, char *fw_ver) | |||
848 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 849 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
849 | OPCODE_COMMON_GET_FW_VERSION, sizeof(*req)); | 850 | OPCODE_COMMON_GET_FW_VERSION, sizeof(*req)); |
850 | 851 | ||
851 | status = be_mbox_db_ring(ctrl); | 852 | status = be_mbox_db_ring(adapter); |
852 | if (!status) { | 853 | if (!status) { |
853 | struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); | 854 | struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); |
854 | strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN); | 855 | strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN); |
855 | } | 856 | } |
856 | 857 | ||
857 | spin_unlock(&ctrl->mbox_lock); | 858 | spin_unlock(&adapter->mbox_lock); |
858 | return status; | 859 | return status; |
859 | } | 860 | } |
860 | 861 | ||
861 | /* set the EQ delay interval of an EQ to specified value */ | 862 | /* set the EQ delay interval of an EQ to specified value */ |
862 | int be_cmd_modify_eqd(struct be_ctrl_info *ctrl, u32 eq_id, u32 eqd) | 863 | int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) |
863 | { | 864 | { |
864 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 865 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
865 | struct be_cmd_req_modify_eq_delay *req = embedded_payload(wrb); | 866 | struct be_cmd_req_modify_eq_delay *req = embedded_payload(wrb); |
866 | int status; | 867 | int status; |
867 | 868 | ||
868 | spin_lock(&ctrl->mbox_lock); | 869 | spin_lock(&adapter->mbox_lock); |
869 | memset(wrb, 0, sizeof(*wrb)); | 870 | memset(wrb, 0, sizeof(*wrb)); |
870 | 871 | ||
871 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 872 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -878,20 +879,20 @@ int be_cmd_modify_eqd(struct be_ctrl_info *ctrl, u32 eq_id, u32 eqd) | |||
878 | req->delay[0].phase = 0; | 879 | req->delay[0].phase = 0; |
879 | req->delay[0].delay_multiplier = cpu_to_le32(eqd); | 880 | req->delay[0].delay_multiplier = cpu_to_le32(eqd); |
880 | 881 | ||
881 | status = be_mbox_db_ring(ctrl); | 882 | status = be_mbox_db_ring(adapter); |
882 | 883 | ||
883 | spin_unlock(&ctrl->mbox_lock); | 884 | spin_unlock(&adapter->mbox_lock); |
884 | return status; | 885 | return status; |
885 | } | 886 | } |
886 | 887 | ||
887 | int be_cmd_vlan_config(struct be_ctrl_info *ctrl, u32 if_id, u16 *vtag_array, | 888 | int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, |
888 | u32 num, bool untagged, bool promiscuous) | 889 | u32 num, bool untagged, bool promiscuous) |
889 | { | 890 | { |
890 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 891 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
891 | struct be_cmd_req_vlan_config *req = embedded_payload(wrb); | 892 | struct be_cmd_req_vlan_config *req = embedded_payload(wrb); |
892 | int status; | 893 | int status; |
893 | 894 | ||
894 | spin_lock(&ctrl->mbox_lock); | 895 | spin_lock(&adapter->mbox_lock); |
895 | memset(wrb, 0, sizeof(*wrb)); | 896 | memset(wrb, 0, sizeof(*wrb)); |
896 | 897 | ||
897 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 898 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -908,21 +909,21 @@ int be_cmd_vlan_config(struct be_ctrl_info *ctrl, u32 if_id, u16 *vtag_array, | |||
908 | req->num_vlan * sizeof(vtag_array[0])); | 909 | req->num_vlan * sizeof(vtag_array[0])); |
909 | } | 910 | } |
910 | 911 | ||
911 | status = be_mbox_db_ring(ctrl); | 912 | status = be_mbox_db_ring(adapter); |
912 | 913 | ||
913 | spin_unlock(&ctrl->mbox_lock); | 914 | spin_unlock(&adapter->mbox_lock); |
914 | return status; | 915 | return status; |
915 | } | 916 | } |
916 | 917 | ||
917 | /* Use MCC for this command as it may be called in BH context */ | 918 | /* Use MCC for this command as it may be called in BH context */ |
918 | int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, u8 port_num, bool en) | 919 | int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) |
919 | { | 920 | { |
920 | struct be_mcc_wrb *wrb; | 921 | struct be_mcc_wrb *wrb; |
921 | struct be_cmd_req_promiscuous_config *req; | 922 | struct be_cmd_req_promiscuous_config *req; |
922 | 923 | ||
923 | spin_lock_bh(&ctrl->mcc_lock); | 924 | spin_lock_bh(&adapter->mcc_lock); |
924 | 925 | ||
925 | wrb = wrb_from_mcc(&ctrl->mcc_obj.q); | 926 | wrb = wrb_from_mcc(&adapter->mcc_obj.q); |
926 | BUG_ON(!wrb); | 927 | BUG_ON(!wrb); |
927 | 928 | ||
928 | req = embedded_payload(wrb); | 929 | req = embedded_payload(wrb); |
@@ -937,9 +938,9 @@ int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, u8 port_num, bool en) | |||
937 | else | 938 | else |
938 | req->port0_promiscuous = en; | 939 | req->port0_promiscuous = en; |
939 | 940 | ||
940 | be_mcc_notify_wait(ctrl); | 941 | be_mcc_notify_wait(adapter); |
941 | 942 | ||
942 | spin_unlock_bh(&ctrl->mcc_lock); | 943 | spin_unlock_bh(&adapter->mcc_lock); |
943 | return 0; | 944 | return 0; |
944 | } | 945 | } |
945 | 946 | ||
@@ -947,16 +948,16 @@ int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, u8 port_num, bool en) | |||
947 | * Use MCC for this command as it may be called in BH context | 948 | * Use MCC for this command as it may be called in BH context |
948 | * (mc == NULL) => multicast promiscous | 949 | * (mc == NULL) => multicast promiscous |
949 | */ | 950 | */ |
950 | int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id, | 951 | int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, |
951 | struct dev_mc_list *mc_list, u32 mc_count) | 952 | struct dev_mc_list *mc_list, u32 mc_count) |
952 | { | 953 | { |
953 | #define BE_MAX_MC 32 /* set mcast promisc if > 32 */ | 954 | #define BE_MAX_MC 32 /* set mcast promisc if > 32 */ |
954 | struct be_mcc_wrb *wrb; | 955 | struct be_mcc_wrb *wrb; |
955 | struct be_cmd_req_mcast_mac_config *req; | 956 | struct be_cmd_req_mcast_mac_config *req; |
956 | 957 | ||
957 | spin_lock_bh(&ctrl->mcc_lock); | 958 | spin_lock_bh(&adapter->mcc_lock); |
958 | 959 | ||
959 | wrb = wrb_from_mcc(&ctrl->mcc_obj.q); | 960 | wrb = wrb_from_mcc(&adapter->mcc_obj.q); |
960 | BUG_ON(!wrb); | 961 | BUG_ON(!wrb); |
961 | 962 | ||
962 | req = embedded_payload(wrb); | 963 | req = embedded_payload(wrb); |
@@ -979,20 +980,20 @@ int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id, | |||
979 | req->promiscuous = 1; | 980 | req->promiscuous = 1; |
980 | } | 981 | } |
981 | 982 | ||
982 | be_mcc_notify_wait(ctrl); | 983 | be_mcc_notify_wait(adapter); |
983 | 984 | ||
984 | spin_unlock_bh(&ctrl->mcc_lock); | 985 | spin_unlock_bh(&adapter->mcc_lock); |
985 | 986 | ||
986 | return 0; | 987 | return 0; |
987 | } | 988 | } |
988 | 989 | ||
989 | int be_cmd_set_flow_control(struct be_ctrl_info *ctrl, u32 tx_fc, u32 rx_fc) | 990 | int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) |
990 | { | 991 | { |
991 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 992 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
992 | struct be_cmd_req_set_flow_control *req = embedded_payload(wrb); | 993 | struct be_cmd_req_set_flow_control *req = embedded_payload(wrb); |
993 | int status; | 994 | int status; |
994 | 995 | ||
995 | spin_lock(&ctrl->mbox_lock); | 996 | spin_lock(&adapter->mbox_lock); |
996 | 997 | ||
997 | memset(wrb, 0, sizeof(*wrb)); | 998 | memset(wrb, 0, sizeof(*wrb)); |
998 | 999 | ||
@@ -1004,19 +1005,19 @@ int be_cmd_set_flow_control(struct be_ctrl_info *ctrl, u32 tx_fc, u32 rx_fc) | |||
1004 | req->tx_flow_control = cpu_to_le16((u16)tx_fc); | 1005 | req->tx_flow_control = cpu_to_le16((u16)tx_fc); |
1005 | req->rx_flow_control = cpu_to_le16((u16)rx_fc); | 1006 | req->rx_flow_control = cpu_to_le16((u16)rx_fc); |
1006 | 1007 | ||
1007 | status = be_mbox_db_ring(ctrl); | 1008 | status = be_mbox_db_ring(adapter); |
1008 | 1009 | ||
1009 | spin_unlock(&ctrl->mbox_lock); | 1010 | spin_unlock(&adapter->mbox_lock); |
1010 | return status; | 1011 | return status; |
1011 | } | 1012 | } |
1012 | 1013 | ||
1013 | int be_cmd_get_flow_control(struct be_ctrl_info *ctrl, u32 *tx_fc, u32 *rx_fc) | 1014 | int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) |
1014 | { | 1015 | { |
1015 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 1016 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
1016 | struct be_cmd_req_get_flow_control *req = embedded_payload(wrb); | 1017 | struct be_cmd_req_get_flow_control *req = embedded_payload(wrb); |
1017 | int status; | 1018 | int status; |
1018 | 1019 | ||
1019 | spin_lock(&ctrl->mbox_lock); | 1020 | spin_lock(&adapter->mbox_lock); |
1020 | 1021 | ||
1021 | memset(wrb, 0, sizeof(*wrb)); | 1022 | memset(wrb, 0, sizeof(*wrb)); |
1022 | 1023 | ||
@@ -1025,7 +1026,7 @@ int be_cmd_get_flow_control(struct be_ctrl_info *ctrl, u32 *tx_fc, u32 *rx_fc) | |||
1025 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 1026 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
1026 | OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req)); | 1027 | OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req)); |
1027 | 1028 | ||
1028 | status = be_mbox_db_ring(ctrl); | 1029 | status = be_mbox_db_ring(adapter); |
1029 | if (!status) { | 1030 | if (!status) { |
1030 | struct be_cmd_resp_get_flow_control *resp = | 1031 | struct be_cmd_resp_get_flow_control *resp = |
1031 | embedded_payload(wrb); | 1032 | embedded_payload(wrb); |
@@ -1033,17 +1034,17 @@ int be_cmd_get_flow_control(struct be_ctrl_info *ctrl, u32 *tx_fc, u32 *rx_fc) | |||
1033 | *rx_fc = le16_to_cpu(resp->rx_flow_control); | 1034 | *rx_fc = le16_to_cpu(resp->rx_flow_control); |
1034 | } | 1035 | } |
1035 | 1036 | ||
1036 | spin_unlock(&ctrl->mbox_lock); | 1037 | spin_unlock(&adapter->mbox_lock); |
1037 | return status; | 1038 | return status; |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | int be_cmd_query_fw_cfg(struct be_ctrl_info *ctrl, u32 *port_num) | 1041 | int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num) |
1041 | { | 1042 | { |
1042 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 1043 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); |
1043 | struct be_cmd_req_query_fw_cfg *req = embedded_payload(wrb); | 1044 | struct be_cmd_req_query_fw_cfg *req = embedded_payload(wrb); |
1044 | int status; | 1045 | int status; |
1045 | 1046 | ||
1046 | spin_lock(&ctrl->mbox_lock); | 1047 | spin_lock(&adapter->mbox_lock); |
1047 | 1048 | ||
1048 | memset(wrb, 0, sizeof(*wrb)); | 1049 | memset(wrb, 0, sizeof(*wrb)); |
1049 | 1050 | ||
@@ -1052,12 +1053,12 @@ int be_cmd_query_fw_cfg(struct be_ctrl_info *ctrl, u32 *port_num) | |||
1052 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 1053 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
1053 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); | 1054 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); |
1054 | 1055 | ||
1055 | status = be_mbox_db_ring(ctrl); | 1056 | status = be_mbox_db_ring(adapter); |
1056 | if (!status) { | 1057 | if (!status) { |
1057 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); | 1058 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); |
1058 | *port_num = le32_to_cpu(resp->phys_port); | 1059 | *port_num = le32_to_cpu(resp->phys_port); |
1059 | } | 1060 | } |
1060 | 1061 | ||
1061 | spin_unlock(&ctrl->mbox_lock); | 1062 | spin_unlock(&adapter->mbox_lock); |
1062 | return status; | 1063 | return status; |
1063 | } | 1064 | } |
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index 747626da7b4..164ab927782 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -634,7 +634,6 @@ struct be_cmd_resp_link_status { | |||
634 | } __packed; | 634 | } __packed; |
635 | 635 | ||
636 | /******************** Get FW Version *******************/ | 636 | /******************** Get FW Version *******************/ |
637 | #define FW_VER_LEN 32 | ||
638 | struct be_cmd_req_get_fw_version { | 637 | struct be_cmd_req_get_fw_version { |
639 | struct be_cmd_req_hdr hdr; | 638 | struct be_cmd_req_hdr hdr; |
640 | u8 rsvd0[FW_VER_LEN]; | 639 | u8 rsvd0[FW_VER_LEN]; |
@@ -697,52 +696,52 @@ struct be_cmd_resp_query_fw_cfg { | |||
697 | u32 rsvd[26]; | 696 | u32 rsvd[26]; |
698 | }; | 697 | }; |
699 | 698 | ||
700 | extern int be_pci_fnum_get(struct be_ctrl_info *ctrl); | 699 | extern int be_pci_fnum_get(struct be_adapter *adapter); |
701 | extern int be_cmd_POST(struct be_ctrl_info *ctrl); | 700 | extern int be_cmd_POST(struct be_adapter *adapter); |
702 | extern int be_cmd_mac_addr_query(struct be_ctrl_info *ctrl, u8 *mac_addr, | 701 | extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, |
703 | u8 type, bool permanent, u32 if_handle); | 702 | u8 type, bool permanent, u32 if_handle); |
704 | extern int be_cmd_pmac_add(struct be_ctrl_info *ctrl, u8 *mac_addr, | 703 | extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
705 | u32 if_id, u32 *pmac_id); | 704 | u32 if_id, u32 *pmac_id); |
706 | extern int be_cmd_pmac_del(struct be_ctrl_info *ctrl, u32 if_id, u32 pmac_id); | 705 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id); |
707 | extern int be_cmd_if_create(struct be_ctrl_info *ctrl, u32 if_flags, u8 *mac, | 706 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 if_flags, u8 *mac, |
708 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id); | 707 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id); |
709 | extern int be_cmd_if_destroy(struct be_ctrl_info *ctrl, u32 if_handle); | 708 | extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle); |
710 | extern int be_cmd_eq_create(struct be_ctrl_info *ctrl, | 709 | extern int be_cmd_eq_create(struct be_adapter *adapter, |
711 | struct be_queue_info *eq, int eq_delay); | 710 | struct be_queue_info *eq, int eq_delay); |
712 | extern int be_cmd_cq_create(struct be_ctrl_info *ctrl, | 711 | extern int be_cmd_cq_create(struct be_adapter *adapter, |
713 | struct be_queue_info *cq, struct be_queue_info *eq, | 712 | struct be_queue_info *cq, struct be_queue_info *eq, |
714 | bool sol_evts, bool no_delay, | 713 | bool sol_evts, bool no_delay, |
715 | int num_cqe_dma_coalesce); | 714 | int num_cqe_dma_coalesce); |
716 | extern int be_cmd_mccq_create(struct be_ctrl_info *ctrl, | 715 | extern int be_cmd_mccq_create(struct be_adapter *adapter, |
717 | struct be_queue_info *mccq, | 716 | struct be_queue_info *mccq, |
718 | struct be_queue_info *cq); | 717 | struct be_queue_info *cq); |
719 | extern int be_cmd_txq_create(struct be_ctrl_info *ctrl, | 718 | extern int be_cmd_txq_create(struct be_adapter *adapter, |
720 | struct be_queue_info *txq, | 719 | struct be_queue_info *txq, |
721 | struct be_queue_info *cq); | 720 | struct be_queue_info *cq); |
722 | extern int be_cmd_rxq_create(struct be_ctrl_info *ctrl, | 721 | extern int be_cmd_rxq_create(struct be_adapter *adapter, |
723 | struct be_queue_info *rxq, u16 cq_id, | 722 | struct be_queue_info *rxq, u16 cq_id, |
724 | u16 frag_size, u16 max_frame_size, u32 if_id, | 723 | u16 frag_size, u16 max_frame_size, u32 if_id, |
725 | u32 rss); | 724 | u32 rss); |
726 | extern int be_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, | 725 | extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, |
727 | int type); | 726 | int type); |
728 | extern int be_cmd_link_status_query(struct be_ctrl_info *ctrl, | 727 | extern int be_cmd_link_status_query(struct be_adapter *adapter, |
729 | bool *link_up); | 728 | bool *link_up); |
730 | extern int be_cmd_reset(struct be_ctrl_info *ctrl); | 729 | extern int be_cmd_reset(struct be_adapter *adapter); |
731 | extern int be_cmd_get_stats(struct be_ctrl_info *ctrl, | 730 | extern int be_cmd_get_stats(struct be_adapter *adapter, |
732 | struct be_dma_mem *nonemb_cmd); | 731 | struct be_dma_mem *nonemb_cmd); |
733 | extern int be_cmd_get_fw_ver(struct be_ctrl_info *ctrl, char *fw_ver); | 732 | extern int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver); |
734 | 733 | ||
735 | extern int be_cmd_modify_eqd(struct be_ctrl_info *ctrl, u32 eq_id, u32 eqd); | 734 | extern int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd); |
736 | extern int be_cmd_vlan_config(struct be_ctrl_info *ctrl, u32 if_id, | 735 | extern int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, |
737 | u16 *vtag_array, u32 num, bool untagged, | 736 | u16 *vtag_array, u32 num, bool untagged, |
738 | bool promiscuous); | 737 | bool promiscuous); |
739 | extern int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, | 738 | extern int be_cmd_promiscuous_config(struct be_adapter *adapter, |
740 | u8 port_num, bool en); | 739 | u8 port_num, bool en); |
741 | extern int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id, | 740 | extern int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, |
742 | struct dev_mc_list *mc_list, u32 mc_count); | 741 | struct dev_mc_list *mc_list, u32 mc_count); |
743 | extern int be_cmd_set_flow_control(struct be_ctrl_info *ctrl, | 742 | extern int be_cmd_set_flow_control(struct be_adapter *adapter, |
744 | u32 tx_fc, u32 rx_fc); | 743 | u32 tx_fc, u32 rx_fc); |
745 | extern int be_cmd_get_flow_control(struct be_ctrl_info *ctrl, | 744 | extern int be_cmd_get_flow_control(struct be_adapter *adapter, |
746 | u32 *tx_fc, u32 *rx_fc); | 745 | u32 *tx_fc, u32 *rx_fc); |
747 | extern int be_cmd_query_fw_cfg(struct be_ctrl_info *ctrl, u32 *port_num); | 746 | extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num); |
748 | extern void be_process_mcc(struct be_ctrl_info *ctrl); | 747 | extern void be_process_mcc(struct be_adapter *adapter); |
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index f3f0f91e38c..c480c19200d 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c | |||
@@ -16,6 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "be.h" | 18 | #include "be.h" |
19 | #include "be_cmds.h" | ||
19 | #include <linux/ethtool.h> | 20 | #include <linux/ethtool.h> |
20 | 21 | ||
21 | struct be_ethtool_stat { | 22 | struct be_ethtool_stat { |
@@ -148,7 +149,6 @@ static int | |||
148 | be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) | 149 | be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) |
149 | { | 150 | { |
150 | struct be_adapter *adapter = netdev_priv(netdev); | 151 | struct be_adapter *adapter = netdev_priv(netdev); |
151 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
152 | struct be_eq_obj *rx_eq = &adapter->rx_eq; | 152 | struct be_eq_obj *rx_eq = &adapter->rx_eq; |
153 | struct be_eq_obj *tx_eq = &adapter->tx_eq; | 153 | struct be_eq_obj *tx_eq = &adapter->tx_eq; |
154 | u32 tx_max, tx_min, tx_cur; | 154 | u32 tx_max, tx_min, tx_cur; |
@@ -176,7 +176,7 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) | |||
176 | if (tx_cur > BE_MAX_EQD) | 176 | if (tx_cur > BE_MAX_EQD) |
177 | tx_cur = BE_MAX_EQD; | 177 | tx_cur = BE_MAX_EQD; |
178 | if (tx_eq->cur_eqd != tx_cur) { | 178 | if (tx_eq->cur_eqd != tx_cur) { |
179 | status = be_cmd_modify_eqd(ctrl, tx_eq->q.id, tx_cur); | 179 | status = be_cmd_modify_eqd(adapter, tx_eq->q.id, tx_cur); |
180 | if (!status) | 180 | if (!status) |
181 | tx_eq->cur_eqd = tx_cur; | 181 | tx_eq->cur_eqd = tx_cur; |
182 | } | 182 | } |
@@ -196,7 +196,8 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) | |||
196 | if (rx_cur > BE_MAX_EQD) | 196 | if (rx_cur > BE_MAX_EQD) |
197 | rx_cur = BE_MAX_EQD; | 197 | rx_cur = BE_MAX_EQD; |
198 | if (rx_eq->cur_eqd != rx_cur) { | 198 | if (rx_eq->cur_eqd != rx_cur) { |
199 | status = be_cmd_modify_eqd(ctrl, rx_eq->q.id, rx_cur); | 199 | status = be_cmd_modify_eqd(adapter, rx_eq->q.id, |
200 | rx_cur); | ||
200 | if (!status) | 201 | if (!status) |
201 | rx_eq->cur_eqd = rx_cur; | 202 | rx_eq->cur_eqd = rx_cur; |
202 | } | 203 | } |
@@ -310,8 +311,7 @@ be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) | |||
310 | { | 311 | { |
311 | struct be_adapter *adapter = netdev_priv(netdev); | 312 | struct be_adapter *adapter = netdev_priv(netdev); |
312 | 313 | ||
313 | be_cmd_get_flow_control(&adapter->ctrl, &ecmd->tx_pause, | 314 | be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause); |
314 | &ecmd->rx_pause); | ||
315 | ecmd->autoneg = 0; | 315 | ecmd->autoneg = 0; |
316 | } | 316 | } |
317 | 317 | ||
@@ -324,7 +324,7 @@ be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) | |||
324 | if (ecmd->autoneg != 0) | 324 | if (ecmd->autoneg != 0) |
325 | return -EINVAL; | 325 | return -EINVAL; |
326 | 326 | ||
327 | status = be_cmd_set_flow_control(&adapter->ctrl, ecmd->tx_pause, | 327 | status = be_cmd_set_flow_control(adapter, ecmd->tx_pause, |
328 | ecmd->rx_pause); | 328 | ecmd->rx_pause); |
329 | if (!status) | 329 | if (!status) |
330 | dev_warn(&adapter->pdev->dev, "Pause param set failed.\n"); | 330 | dev_warn(&adapter->pdev->dev, "Pause param set failed.\n"); |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index c56487e3700..da5341f1038 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -16,6 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "be.h" | 18 | #include "be.h" |
19 | #include "be_cmds.h" | ||
19 | #include <asm/div64.h> | 20 | #include <asm/div64.h> |
20 | 21 | ||
21 | MODULE_VERSION(DRV_VER); | 22 | MODULE_VERSION(DRV_VER); |
@@ -60,9 +61,9 @@ static int be_queue_alloc(struct be_adapter *adapter, struct be_queue_info *q, | |||
60 | return 0; | 61 | return 0; |
61 | } | 62 | } |
62 | 63 | ||
63 | static void be_intr_set(struct be_ctrl_info *ctrl, bool enable) | 64 | static void be_intr_set(struct be_adapter *adapter, bool enable) |
64 | { | 65 | { |
65 | u8 __iomem *addr = ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET; | 66 | u8 __iomem *addr = adapter->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET; |
66 | u32 reg = ioread32(addr); | 67 | u32 reg = ioread32(addr); |
67 | u32 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; | 68 | u32 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; |
68 | if (!enabled && enable) { | 69 | if (!enabled && enable) { |
@@ -77,23 +78,23 @@ static void be_intr_set(struct be_ctrl_info *ctrl, bool enable) | |||
77 | iowrite32(reg, addr); | 78 | iowrite32(reg, addr); |
78 | } | 79 | } |
79 | 80 | ||
80 | static void be_rxq_notify(struct be_ctrl_info *ctrl, u16 qid, u16 posted) | 81 | static void be_rxq_notify(struct be_adapter *adapter, u16 qid, u16 posted) |
81 | { | 82 | { |
82 | u32 val = 0; | 83 | u32 val = 0; |
83 | val |= qid & DB_RQ_RING_ID_MASK; | 84 | val |= qid & DB_RQ_RING_ID_MASK; |
84 | val |= posted << DB_RQ_NUM_POSTED_SHIFT; | 85 | val |= posted << DB_RQ_NUM_POSTED_SHIFT; |
85 | iowrite32(val, ctrl->db + DB_RQ_OFFSET); | 86 | iowrite32(val, adapter->db + DB_RQ_OFFSET); |
86 | } | 87 | } |
87 | 88 | ||
88 | static void be_txq_notify(struct be_ctrl_info *ctrl, u16 qid, u16 posted) | 89 | static void be_txq_notify(struct be_adapter *adapter, u16 qid, u16 posted) |
89 | { | 90 | { |
90 | u32 val = 0; | 91 | u32 val = 0; |
91 | val |= qid & DB_TXULP_RING_ID_MASK; | 92 | val |= qid & DB_TXULP_RING_ID_MASK; |
92 | val |= (posted & DB_TXULP_NUM_POSTED_MASK) << DB_TXULP_NUM_POSTED_SHIFT; | 93 | val |= (posted & DB_TXULP_NUM_POSTED_MASK) << DB_TXULP_NUM_POSTED_SHIFT; |
93 | iowrite32(val, ctrl->db + DB_TXULP1_OFFSET); | 94 | iowrite32(val, adapter->db + DB_TXULP1_OFFSET); |
94 | } | 95 | } |
95 | 96 | ||
96 | static void be_eq_notify(struct be_ctrl_info *ctrl, u16 qid, | 97 | static void be_eq_notify(struct be_adapter *adapter, u16 qid, |
97 | bool arm, bool clear_int, u16 num_popped) | 98 | bool arm, bool clear_int, u16 num_popped) |
98 | { | 99 | { |
99 | u32 val = 0; | 100 | u32 val = 0; |
@@ -104,18 +105,17 @@ static void be_eq_notify(struct be_ctrl_info *ctrl, u16 qid, | |||
104 | val |= 1 << DB_EQ_CLR_SHIFT; | 105 | val |= 1 << DB_EQ_CLR_SHIFT; |
105 | val |= 1 << DB_EQ_EVNT_SHIFT; | 106 | val |= 1 << DB_EQ_EVNT_SHIFT; |
106 | val |= num_popped << DB_EQ_NUM_POPPED_SHIFT; | 107 | val |= num_popped << DB_EQ_NUM_POPPED_SHIFT; |
107 | iowrite32(val, ctrl->db + DB_EQ_OFFSET); | 108 | iowrite32(val, adapter->db + DB_EQ_OFFSET); |
108 | } | 109 | } |
109 | 110 | ||
110 | void be_cq_notify(struct be_ctrl_info *ctrl, u16 qid, | 111 | void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped) |
111 | bool arm, u16 num_popped) | ||
112 | { | 112 | { |
113 | u32 val = 0; | 113 | u32 val = 0; |
114 | val |= qid & DB_CQ_RING_ID_MASK; | 114 | val |= qid & DB_CQ_RING_ID_MASK; |
115 | if (arm) | 115 | if (arm) |
116 | val |= 1 << DB_CQ_REARM_SHIFT; | 116 | val |= 1 << DB_CQ_REARM_SHIFT; |
117 | val |= num_popped << DB_CQ_NUM_POPPED_SHIFT; | 117 | val |= num_popped << DB_CQ_NUM_POPPED_SHIFT; |
118 | iowrite32(val, ctrl->db + DB_CQ_OFFSET); | 118 | iowrite32(val, adapter->db + DB_CQ_OFFSET); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
@@ -126,12 +126,12 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) | |||
126 | int status = 0; | 126 | int status = 0; |
127 | 127 | ||
128 | if (netif_running(netdev)) { | 128 | if (netif_running(netdev)) { |
129 | status = be_cmd_pmac_del(&adapter->ctrl, adapter->if_handle, | 129 | status = be_cmd_pmac_del(adapter, adapter->if_handle, |
130 | adapter->pmac_id); | 130 | adapter->pmac_id); |
131 | if (status) | 131 | if (status) |
132 | return status; | 132 | return status; |
133 | 133 | ||
134 | status = be_cmd_pmac_add(&adapter->ctrl, (u8 *)addr->sa_data, | 134 | status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data, |
135 | adapter->if_handle, &adapter->pmac_id); | 135 | adapter->if_handle, &adapter->pmac_id); |
136 | } | 136 | } |
137 | 137 | ||
@@ -214,9 +214,8 @@ static void netdev_stats_update(struct be_adapter *adapter) | |||
214 | dev_stats->tx_window_errors = 0; | 214 | dev_stats->tx_window_errors = 0; |
215 | } | 215 | } |
216 | 216 | ||
217 | void be_link_status_update(void *ctxt, bool link_up) | 217 | void be_link_status_update(struct be_adapter *adapter, bool link_up) |
218 | { | 218 | { |
219 | struct be_adapter *adapter = ctxt; | ||
220 | struct net_device *netdev = adapter->netdev; | 219 | struct net_device *netdev = adapter->netdev; |
221 | 220 | ||
222 | /* If link came up or went down */ | 221 | /* If link came up or went down */ |
@@ -237,7 +236,6 @@ void be_link_status_update(void *ctxt, bool link_up) | |||
237 | /* Update the EQ delay n BE based on the RX frags consumed / sec */ | 236 | /* Update the EQ delay n BE based on the RX frags consumed / sec */ |
238 | static void be_rx_eqd_update(struct be_adapter *adapter) | 237 | static void be_rx_eqd_update(struct be_adapter *adapter) |
239 | { | 238 | { |
240 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
241 | struct be_eq_obj *rx_eq = &adapter->rx_eq; | 239 | struct be_eq_obj *rx_eq = &adapter->rx_eq; |
242 | struct be_drvr_stats *stats = &adapter->stats.drvr_stats; | 240 | struct be_drvr_stats *stats = &adapter->stats.drvr_stats; |
243 | ulong now = jiffies; | 241 | ulong now = jiffies; |
@@ -270,7 +268,7 @@ static void be_rx_eqd_update(struct be_adapter *adapter) | |||
270 | if (eqd < 10) | 268 | if (eqd < 10) |
271 | eqd = 0; | 269 | eqd = 0; |
272 | if (eqd != rx_eq->cur_eqd) | 270 | if (eqd != rx_eq->cur_eqd) |
273 | be_cmd_modify_eqd(ctrl, rx_eq->q.id, eqd); | 271 | be_cmd_modify_eqd(adapter, rx_eq->q.id, eqd); |
274 | 272 | ||
275 | rx_eq->cur_eqd = eqd; | 273 | rx_eq->cur_eqd = eqd; |
276 | } | 274 | } |
@@ -412,8 +410,8 @@ static int make_tx_wrbs(struct be_adapter *adapter, | |||
412 | struct skb_frag_struct *frag = | 410 | struct skb_frag_struct *frag = |
413 | &skb_shinfo(skb)->frags[i]; | 411 | &skb_shinfo(skb)->frags[i]; |
414 | busaddr = pci_map_page(pdev, frag->page, | 412 | busaddr = pci_map_page(pdev, frag->page, |
415 | frag->page_offset, | 413 | frag->page_offset, |
416 | frag->size, PCI_DMA_TODEVICE); | 414 | frag->size, PCI_DMA_TODEVICE); |
417 | wrb = queue_head_node(txq); | 415 | wrb = queue_head_node(txq); |
418 | wrb_fill(wrb, busaddr, frag->size); | 416 | wrb_fill(wrb, busaddr, frag->size); |
419 | be_dws_cpu_to_le(wrb, sizeof(*wrb)); | 417 | be_dws_cpu_to_le(wrb, sizeof(*wrb)); |
@@ -461,7 +459,7 @@ static int be_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
461 | stopped = true; | 459 | stopped = true; |
462 | } | 460 | } |
463 | 461 | ||
464 | be_txq_notify(&adapter->ctrl, txq->id, wrb_cnt); | 462 | be_txq_notify(adapter, txq->id, wrb_cnt); |
465 | 463 | ||
466 | be_tx_stats_update(adapter, wrb_cnt, copied, stopped); | 464 | be_tx_stats_update(adapter, wrb_cnt, copied, stopped); |
467 | return NETDEV_TX_OK; | 465 | return NETDEV_TX_OK; |
@@ -502,10 +500,10 @@ static void be_vid_config(struct net_device *netdev) | |||
502 | ntags++; | 500 | ntags++; |
503 | } | 501 | } |
504 | } | 502 | } |
505 | be_cmd_vlan_config(&adapter->ctrl, adapter->if_handle, | 503 | be_cmd_vlan_config(adapter, adapter->if_handle, |
506 | vtag, ntags, 1, 0); | 504 | vtag, ntags, 1, 0); |
507 | } else { | 505 | } else { |
508 | be_cmd_vlan_config(&adapter->ctrl, adapter->if_handle, | 506 | be_cmd_vlan_config(adapter, adapter->if_handle, |
509 | NULL, 0, 1, 1); | 507 | NULL, 0, 1, 1); |
510 | } | 508 | } |
511 | } | 509 | } |
@@ -515,13 +513,12 @@ static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp) | |||
515 | struct be_adapter *adapter = netdev_priv(netdev); | 513 | struct be_adapter *adapter = netdev_priv(netdev); |
516 | struct be_eq_obj *rx_eq = &adapter->rx_eq; | 514 | struct be_eq_obj *rx_eq = &adapter->rx_eq; |
517 | struct be_eq_obj *tx_eq = &adapter->tx_eq; | 515 | struct be_eq_obj *tx_eq = &adapter->tx_eq; |
518 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
519 | 516 | ||
520 | be_eq_notify(ctrl, rx_eq->q.id, false, false, 0); | 517 | be_eq_notify(adapter, rx_eq->q.id, false, false, 0); |
521 | be_eq_notify(ctrl, tx_eq->q.id, false, false, 0); | 518 | be_eq_notify(adapter, tx_eq->q.id, false, false, 0); |
522 | adapter->vlan_grp = grp; | 519 | adapter->vlan_grp = grp; |
523 | be_eq_notify(ctrl, rx_eq->q.id, true, false, 0); | 520 | be_eq_notify(adapter, rx_eq->q.id, true, false, 0); |
524 | be_eq_notify(ctrl, tx_eq->q.id, true, false, 0); | 521 | be_eq_notify(adapter, tx_eq->q.id, true, false, 0); |
525 | } | 522 | } |
526 | 523 | ||
527 | static void be_vlan_add_vid(struct net_device *netdev, u16 vid) | 524 | static void be_vlan_add_vid(struct net_device *netdev, u16 vid) |
@@ -548,10 +545,9 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) | |||
548 | static void be_set_multicast_list(struct net_device *netdev) | 545 | static void be_set_multicast_list(struct net_device *netdev) |
549 | { | 546 | { |
550 | struct be_adapter *adapter = netdev_priv(netdev); | 547 | struct be_adapter *adapter = netdev_priv(netdev); |
551 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
552 | 548 | ||
553 | if (netdev->flags & IFF_PROMISC) { | 549 | if (netdev->flags & IFF_PROMISC) { |
554 | be_cmd_promiscuous_config(ctrl, adapter->port_num, 1); | 550 | be_cmd_promiscuous_config(adapter, adapter->port_num, 1); |
555 | adapter->promiscuous = true; | 551 | adapter->promiscuous = true; |
556 | goto done; | 552 | goto done; |
557 | } | 553 | } |
@@ -559,15 +555,15 @@ static void be_set_multicast_list(struct net_device *netdev) | |||
559 | /* BE was previously in promiscous mode; disable it */ | 555 | /* BE was previously in promiscous mode; disable it */ |
560 | if (adapter->promiscuous) { | 556 | if (adapter->promiscuous) { |
561 | adapter->promiscuous = false; | 557 | adapter->promiscuous = false; |
562 | be_cmd_promiscuous_config(ctrl, adapter->port_num, 0); | 558 | be_cmd_promiscuous_config(adapter, adapter->port_num, 0); |
563 | } | 559 | } |
564 | 560 | ||
565 | if (netdev->flags & IFF_ALLMULTI) { | 561 | if (netdev->flags & IFF_ALLMULTI) { |
566 | be_cmd_multicast_set(ctrl, adapter->if_handle, NULL, 0); | 562 | be_cmd_multicast_set(adapter, adapter->if_handle, NULL, 0); |
567 | goto done; | 563 | goto done; |
568 | } | 564 | } |
569 | 565 | ||
570 | be_cmd_multicast_set(ctrl, adapter->if_handle, netdev->mc_list, | 566 | be_cmd_multicast_set(adapter, adapter->if_handle, netdev->mc_list, |
571 | netdev->mc_count); | 567 | netdev->mc_count); |
572 | done: | 568 | done: |
573 | return; | 569 | return; |
@@ -942,7 +938,7 @@ static void be_post_rx_frags(struct be_adapter *adapter) | |||
942 | 938 | ||
943 | if (posted) { | 939 | if (posted) { |
944 | atomic_add(posted, &rxq->used); | 940 | atomic_add(posted, &rxq->used); |
945 | be_rxq_notify(&adapter->ctrl, rxq->id, posted); | 941 | be_rxq_notify(adapter, rxq->id, posted); |
946 | } else if (atomic_read(&rxq->used) == 0) { | 942 | } else if (atomic_read(&rxq->used) == 0) { |
947 | /* Let be_worker replenish when memory is available */ | 943 | /* Let be_worker replenish when memory is available */ |
948 | adapter->rx_post_starved = true; | 944 | adapter->rx_post_starved = true; |
@@ -1010,7 +1006,7 @@ static void be_rx_q_clean(struct be_adapter *adapter) | |||
1010 | while ((rxcp = be_rx_compl_get(adapter)) != NULL) { | 1006 | while ((rxcp = be_rx_compl_get(adapter)) != NULL) { |
1011 | be_rx_compl_discard(adapter, rxcp); | 1007 | be_rx_compl_discard(adapter, rxcp); |
1012 | be_rx_compl_reset(rxcp); | 1008 | be_rx_compl_reset(rxcp); |
1013 | be_cq_notify(&adapter->ctrl, rx_cq->id, true, 1); | 1009 | be_cq_notify(adapter, rx_cq->id, true, 1); |
1014 | } | 1010 | } |
1015 | 1011 | ||
1016 | /* Then free posted rx buffer that were not used */ | 1012 | /* Then free posted rx buffer that were not used */ |
@@ -1043,16 +1039,15 @@ static void be_tx_q_clean(struct be_adapter *adapter) | |||
1043 | static void be_mcc_queues_destroy(struct be_adapter *adapter) | 1039 | static void be_mcc_queues_destroy(struct be_adapter *adapter) |
1044 | { | 1040 | { |
1045 | struct be_queue_info *q; | 1041 | struct be_queue_info *q; |
1046 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1047 | 1042 | ||
1048 | q = &ctrl->mcc_obj.q; | 1043 | q = &adapter->mcc_obj.q; |
1049 | if (q->created) | 1044 | if (q->created) |
1050 | be_cmd_q_destroy(ctrl, q, QTYPE_MCCQ); | 1045 | be_cmd_q_destroy(adapter, q, QTYPE_MCCQ); |
1051 | be_queue_free(adapter, q); | 1046 | be_queue_free(adapter, q); |
1052 | 1047 | ||
1053 | q = &ctrl->mcc_obj.cq; | 1048 | q = &adapter->mcc_obj.cq; |
1054 | if (q->created) | 1049 | if (q->created) |
1055 | be_cmd_q_destroy(ctrl, q, QTYPE_CQ); | 1050 | be_cmd_q_destroy(adapter, q, QTYPE_CQ); |
1056 | be_queue_free(adapter, q); | 1051 | be_queue_free(adapter, q); |
1057 | } | 1052 | } |
1058 | 1053 | ||
@@ -1060,25 +1055,24 @@ static void be_mcc_queues_destroy(struct be_adapter *adapter) | |||
1060 | static int be_mcc_queues_create(struct be_adapter *adapter) | 1055 | static int be_mcc_queues_create(struct be_adapter *adapter) |
1061 | { | 1056 | { |
1062 | struct be_queue_info *q, *cq; | 1057 | struct be_queue_info *q, *cq; |
1063 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1064 | 1058 | ||
1065 | /* Alloc MCC compl queue */ | 1059 | /* Alloc MCC compl queue */ |
1066 | cq = &ctrl->mcc_obj.cq; | 1060 | cq = &adapter->mcc_obj.cq; |
1067 | if (be_queue_alloc(adapter, cq, MCC_CQ_LEN, | 1061 | if (be_queue_alloc(adapter, cq, MCC_CQ_LEN, |
1068 | sizeof(struct be_mcc_cq_entry))) | 1062 | sizeof(struct be_mcc_cq_entry))) |
1069 | goto err; | 1063 | goto err; |
1070 | 1064 | ||
1071 | /* Ask BE to create MCC compl queue; share TX's eq */ | 1065 | /* Ask BE to create MCC compl queue; share TX's eq */ |
1072 | if (be_cmd_cq_create(ctrl, cq, &adapter->tx_eq.q, false, true, 0)) | 1066 | if (be_cmd_cq_create(adapter, cq, &adapter->tx_eq.q, false, true, 0)) |
1073 | goto mcc_cq_free; | 1067 | goto mcc_cq_free; |
1074 | 1068 | ||
1075 | /* Alloc MCC queue */ | 1069 | /* Alloc MCC queue */ |
1076 | q = &ctrl->mcc_obj.q; | 1070 | q = &adapter->mcc_obj.q; |
1077 | if (be_queue_alloc(adapter, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) | 1071 | if (be_queue_alloc(adapter, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) |
1078 | goto mcc_cq_destroy; | 1072 | goto mcc_cq_destroy; |
1079 | 1073 | ||
1080 | /* Ask BE to create MCC queue */ | 1074 | /* Ask BE to create MCC queue */ |
1081 | if (be_cmd_mccq_create(ctrl, q, cq)) | 1075 | if (be_cmd_mccq_create(adapter, q, cq)) |
1082 | goto mcc_q_free; | 1076 | goto mcc_q_free; |
1083 | 1077 | ||
1084 | return 0; | 1078 | return 0; |
@@ -1086,7 +1080,7 @@ static int be_mcc_queues_create(struct be_adapter *adapter) | |||
1086 | mcc_q_free: | 1080 | mcc_q_free: |
1087 | be_queue_free(adapter, q); | 1081 | be_queue_free(adapter, q); |
1088 | mcc_cq_destroy: | 1082 | mcc_cq_destroy: |
1089 | be_cmd_q_destroy(ctrl, cq, QTYPE_CQ); | 1083 | be_cmd_q_destroy(adapter, cq, QTYPE_CQ); |
1090 | mcc_cq_free: | 1084 | mcc_cq_free: |
1091 | be_queue_free(adapter, cq); | 1085 | be_queue_free(adapter, cq); |
1092 | err: | 1086 | err: |
@@ -1099,7 +1093,7 @@ static void be_tx_queues_destroy(struct be_adapter *adapter) | |||
1099 | 1093 | ||
1100 | q = &adapter->tx_obj.q; | 1094 | q = &adapter->tx_obj.q; |
1101 | if (q->created) { | 1095 | if (q->created) { |
1102 | be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_TXQ); | 1096 | be_cmd_q_destroy(adapter, q, QTYPE_TXQ); |
1103 | 1097 | ||
1104 | /* No more tx completions can be rcvd now; clean up if there | 1098 | /* No more tx completions can be rcvd now; clean up if there |
1105 | * are any pending completions or pending tx requests */ | 1099 | * are any pending completions or pending tx requests */ |
@@ -1109,12 +1103,12 @@ static void be_tx_queues_destroy(struct be_adapter *adapter) | |||
1109 | 1103 | ||
1110 | q = &adapter->tx_obj.cq; | 1104 | q = &adapter->tx_obj.cq; |
1111 | if (q->created) | 1105 | if (q->created) |
1112 | be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_CQ); | 1106 | be_cmd_q_destroy(adapter, q, QTYPE_CQ); |
1113 | be_queue_free(adapter, q); | 1107 | be_queue_free(adapter, q); |
1114 | 1108 | ||
1115 | q = &adapter->tx_eq.q; | 1109 | q = &adapter->tx_eq.q; |
1116 | if (q->created) | 1110 | if (q->created) |
1117 | be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_EQ); | 1111 | be_cmd_q_destroy(adapter, q, QTYPE_EQ); |
1118 | be_queue_free(adapter, q); | 1112 | be_queue_free(adapter, q); |
1119 | } | 1113 | } |
1120 | 1114 | ||
@@ -1132,7 +1126,7 @@ static int be_tx_queues_create(struct be_adapter *adapter) | |||
1132 | return -1; | 1126 | return -1; |
1133 | 1127 | ||
1134 | /* Ask BE to create Tx Event queue */ | 1128 | /* Ask BE to create Tx Event queue */ |
1135 | if (be_cmd_eq_create(&adapter->ctrl, eq, adapter->tx_eq.cur_eqd)) | 1129 | if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd)) |
1136 | goto tx_eq_free; | 1130 | goto tx_eq_free; |
1137 | /* Alloc TX eth compl queue */ | 1131 | /* Alloc TX eth compl queue */ |
1138 | cq = &adapter->tx_obj.cq; | 1132 | cq = &adapter->tx_obj.cq; |
@@ -1141,7 +1135,7 @@ static int be_tx_queues_create(struct be_adapter *adapter) | |||
1141 | goto tx_eq_destroy; | 1135 | goto tx_eq_destroy; |
1142 | 1136 | ||
1143 | /* Ask BE to create Tx eth compl queue */ | 1137 | /* Ask BE to create Tx eth compl queue */ |
1144 | if (be_cmd_cq_create(&adapter->ctrl, cq, eq, false, false, 3)) | 1138 | if (be_cmd_cq_create(adapter, cq, eq, false, false, 3)) |
1145 | goto tx_cq_free; | 1139 | goto tx_cq_free; |
1146 | 1140 | ||
1147 | /* Alloc TX eth queue */ | 1141 | /* Alloc TX eth queue */ |
@@ -1150,18 +1144,18 @@ static int be_tx_queues_create(struct be_adapter *adapter) | |||
1150 | goto tx_cq_destroy; | 1144 | goto tx_cq_destroy; |
1151 | 1145 | ||
1152 | /* Ask BE to create Tx eth queue */ | 1146 | /* Ask BE to create Tx eth queue */ |
1153 | if (be_cmd_txq_create(&adapter->ctrl, q, cq)) | 1147 | if (be_cmd_txq_create(adapter, q, cq)) |
1154 | goto tx_q_free; | 1148 | goto tx_q_free; |
1155 | return 0; | 1149 | return 0; |
1156 | 1150 | ||
1157 | tx_q_free: | 1151 | tx_q_free: |
1158 | be_queue_free(adapter, q); | 1152 | be_queue_free(adapter, q); |
1159 | tx_cq_destroy: | 1153 | tx_cq_destroy: |
1160 | be_cmd_q_destroy(&adapter->ctrl, cq, QTYPE_CQ); | 1154 | be_cmd_q_destroy(adapter, cq, QTYPE_CQ); |
1161 | tx_cq_free: | 1155 | tx_cq_free: |
1162 | be_queue_free(adapter, cq); | 1156 | be_queue_free(adapter, cq); |
1163 | tx_eq_destroy: | 1157 | tx_eq_destroy: |
1164 | be_cmd_q_destroy(&adapter->ctrl, eq, QTYPE_EQ); | 1158 | be_cmd_q_destroy(adapter, eq, QTYPE_EQ); |
1165 | tx_eq_free: | 1159 | tx_eq_free: |
1166 | be_queue_free(adapter, eq); | 1160 | be_queue_free(adapter, eq); |
1167 | return -1; | 1161 | return -1; |
@@ -1173,19 +1167,19 @@ static void be_rx_queues_destroy(struct be_adapter *adapter) | |||
1173 | 1167 | ||
1174 | q = &adapter->rx_obj.q; | 1168 | q = &adapter->rx_obj.q; |
1175 | if (q->created) { | 1169 | if (q->created) { |
1176 | be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_RXQ); | 1170 | be_cmd_q_destroy(adapter, q, QTYPE_RXQ); |
1177 | be_rx_q_clean(adapter); | 1171 | be_rx_q_clean(adapter); |
1178 | } | 1172 | } |
1179 | be_queue_free(adapter, q); | 1173 | be_queue_free(adapter, q); |
1180 | 1174 | ||
1181 | q = &adapter->rx_obj.cq; | 1175 | q = &adapter->rx_obj.cq; |
1182 | if (q->created) | 1176 | if (q->created) |
1183 | be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_CQ); | 1177 | be_cmd_q_destroy(adapter, q, QTYPE_CQ); |
1184 | be_queue_free(adapter, q); | 1178 | be_queue_free(adapter, q); |
1185 | 1179 | ||
1186 | q = &adapter->rx_eq.q; | 1180 | q = &adapter->rx_eq.q; |
1187 | if (q->created) | 1181 | if (q->created) |
1188 | be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_EQ); | 1182 | be_cmd_q_destroy(adapter, q, QTYPE_EQ); |
1189 | be_queue_free(adapter, q); | 1183 | be_queue_free(adapter, q); |
1190 | } | 1184 | } |
1191 | 1185 | ||
@@ -1208,7 +1202,7 @@ static int be_rx_queues_create(struct be_adapter *adapter) | |||
1208 | return rc; | 1202 | return rc; |
1209 | 1203 | ||
1210 | /* Ask BE to create Rx Event queue */ | 1204 | /* Ask BE to create Rx Event queue */ |
1211 | rc = be_cmd_eq_create(&adapter->ctrl, eq, adapter->rx_eq.cur_eqd); | 1205 | rc = be_cmd_eq_create(adapter, eq, adapter->rx_eq.cur_eqd); |
1212 | if (rc) | 1206 | if (rc) |
1213 | goto rx_eq_free; | 1207 | goto rx_eq_free; |
1214 | 1208 | ||
@@ -1220,7 +1214,7 @@ static int be_rx_queues_create(struct be_adapter *adapter) | |||
1220 | goto rx_eq_destroy; | 1214 | goto rx_eq_destroy; |
1221 | 1215 | ||
1222 | /* Ask BE to create Rx eth compl queue */ | 1216 | /* Ask BE to create Rx eth compl queue */ |
1223 | rc = be_cmd_cq_create(&adapter->ctrl, cq, eq, false, false, 3); | 1217 | rc = be_cmd_cq_create(adapter, cq, eq, false, false, 3); |
1224 | if (rc) | 1218 | if (rc) |
1225 | goto rx_cq_free; | 1219 | goto rx_cq_free; |
1226 | 1220 | ||
@@ -1231,7 +1225,7 @@ static int be_rx_queues_create(struct be_adapter *adapter) | |||
1231 | goto rx_cq_destroy; | 1225 | goto rx_cq_destroy; |
1232 | 1226 | ||
1233 | /* Ask BE to create Rx eth queue */ | 1227 | /* Ask BE to create Rx eth queue */ |
1234 | rc = be_cmd_rxq_create(&adapter->ctrl, q, cq->id, rx_frag_size, | 1228 | rc = be_cmd_rxq_create(adapter, q, cq->id, rx_frag_size, |
1235 | BE_MAX_JUMBO_FRAME_SIZE, adapter->if_handle, false); | 1229 | BE_MAX_JUMBO_FRAME_SIZE, adapter->if_handle, false); |
1236 | if (rc) | 1230 | if (rc) |
1237 | goto rx_q_free; | 1231 | goto rx_q_free; |
@@ -1240,11 +1234,11 @@ static int be_rx_queues_create(struct be_adapter *adapter) | |||
1240 | rx_q_free: | 1234 | rx_q_free: |
1241 | be_queue_free(adapter, q); | 1235 | be_queue_free(adapter, q); |
1242 | rx_cq_destroy: | 1236 | rx_cq_destroy: |
1243 | be_cmd_q_destroy(&adapter->ctrl, cq, QTYPE_CQ); | 1237 | be_cmd_q_destroy(adapter, cq, QTYPE_CQ); |
1244 | rx_cq_free: | 1238 | rx_cq_free: |
1245 | be_queue_free(adapter, cq); | 1239 | be_queue_free(adapter, cq); |
1246 | rx_eq_destroy: | 1240 | rx_eq_destroy: |
1247 | be_cmd_q_destroy(&adapter->ctrl, eq, QTYPE_EQ); | 1241 | be_cmd_q_destroy(adapter, eq, QTYPE_EQ); |
1248 | rx_eq_free: | 1242 | rx_eq_free: |
1249 | be_queue_free(adapter, eq); | 1243 | be_queue_free(adapter, eq); |
1250 | return rc; | 1244 | return rc; |
@@ -1264,8 +1258,7 @@ static bool event_get(struct be_eq_obj *eq_obj, u16 *rid) | |||
1264 | return true; | 1258 | return true; |
1265 | } | 1259 | } |
1266 | 1260 | ||
1267 | static int event_handle(struct be_ctrl_info *ctrl, | 1261 | static int event_handle(struct be_adapter *adapter, struct be_eq_obj *eq_obj) |
1268 | struct be_eq_obj *eq_obj) | ||
1269 | { | 1262 | { |
1270 | u16 rid = 0, num = 0; | 1263 | u16 rid = 0, num = 0; |
1271 | 1264 | ||
@@ -1273,7 +1266,7 @@ static int event_handle(struct be_ctrl_info *ctrl, | |||
1273 | num++; | 1266 | num++; |
1274 | 1267 | ||
1275 | /* We can see an interrupt and no event */ | 1268 | /* We can see an interrupt and no event */ |
1276 | be_eq_notify(ctrl, eq_obj->q.id, true, true, num); | 1269 | be_eq_notify(adapter, eq_obj->q.id, true, true, num); |
1277 | if (num) | 1270 | if (num) |
1278 | napi_schedule(&eq_obj->napi); | 1271 | napi_schedule(&eq_obj->napi); |
1279 | 1272 | ||
@@ -1283,25 +1276,24 @@ static int event_handle(struct be_ctrl_info *ctrl, | |||
1283 | static irqreturn_t be_intx(int irq, void *dev) | 1276 | static irqreturn_t be_intx(int irq, void *dev) |
1284 | { | 1277 | { |
1285 | struct be_adapter *adapter = dev; | 1278 | struct be_adapter *adapter = dev; |
1286 | struct be_ctrl_info *ctrl = &adapter->ctrl; | 1279 | int isr; |
1287 | int isr; | ||
1288 | 1280 | ||
1289 | isr = ioread32(ctrl->csr + CEV_ISR0_OFFSET + | 1281 | isr = ioread32(adapter->csr + CEV_ISR0_OFFSET + |
1290 | ctrl->pci_func * CEV_ISR_SIZE); | 1282 | adapter->pci_func * CEV_ISR_SIZE); |
1291 | if (!isr) | 1283 | if (!isr) |
1292 | return IRQ_NONE; | 1284 | return IRQ_NONE; |
1293 | 1285 | ||
1294 | event_handle(ctrl, &adapter->tx_eq); | 1286 | event_handle(adapter, &adapter->tx_eq); |
1295 | event_handle(ctrl, &adapter->rx_eq); | 1287 | event_handle(adapter, &adapter->rx_eq); |
1296 | 1288 | ||
1297 | return IRQ_HANDLED; | 1289 | return IRQ_HANDLED; |
1298 | } | 1290 | } |
1299 | 1291 | ||
1300 | static irqreturn_t be_msix_rx(int irq, void *dev) | 1292 | static irqreturn_t be_msix_rx(int irq, void *dev) |
1301 | { | 1293 | { |
1302 | struct be_adapter *adapter = dev; | 1294 | struct be_adapter *adapter = dev; |
1303 | 1295 | ||
1304 | event_handle(&adapter->ctrl, &adapter->rx_eq); | 1296 | event_handle(adapter, &adapter->rx_eq); |
1305 | 1297 | ||
1306 | return IRQ_HANDLED; | 1298 | return IRQ_HANDLED; |
1307 | } | 1299 | } |
@@ -1310,7 +1302,7 @@ static irqreturn_t be_msix_tx_mcc(int irq, void *dev) | |||
1310 | { | 1302 | { |
1311 | struct be_adapter *adapter = dev; | 1303 | struct be_adapter *adapter = dev; |
1312 | 1304 | ||
1313 | event_handle(&adapter->ctrl, &adapter->tx_eq); | 1305 | event_handle(adapter, &adapter->tx_eq); |
1314 | 1306 | ||
1315 | return IRQ_HANDLED; | 1307 | return IRQ_HANDLED; |
1316 | } | 1308 | } |
@@ -1356,10 +1348,10 @@ int be_poll_rx(struct napi_struct *napi, int budget) | |||
1356 | /* All consumed */ | 1348 | /* All consumed */ |
1357 | if (work_done < budget) { | 1349 | if (work_done < budget) { |
1358 | napi_complete(napi); | 1350 | napi_complete(napi); |
1359 | be_cq_notify(&adapter->ctrl, rx_cq->id, true, work_done); | 1351 | be_cq_notify(adapter, rx_cq->id, true, work_done); |
1360 | } else { | 1352 | } else { |
1361 | /* More to be consumed; continue with interrupts disabled */ | 1353 | /* More to be consumed; continue with interrupts disabled */ |
1362 | be_cq_notify(&adapter->ctrl, rx_cq->id, false, work_done); | 1354 | be_cq_notify(adapter, rx_cq->id, false, work_done); |
1363 | } | 1355 | } |
1364 | return work_done; | 1356 | return work_done; |
1365 | } | 1357 | } |
@@ -1380,7 +1372,7 @@ void be_process_tx(struct be_adapter *adapter) | |||
1380 | } | 1372 | } |
1381 | 1373 | ||
1382 | if (num_cmpl) { | 1374 | if (num_cmpl) { |
1383 | be_cq_notify(&adapter->ctrl, tx_cq->id, true, num_cmpl); | 1375 | be_cq_notify(adapter, tx_cq->id, true, num_cmpl); |
1384 | 1376 | ||
1385 | /* As Tx wrbs have been freed up, wake up netdev queue if | 1377 | /* As Tx wrbs have been freed up, wake up netdev queue if |
1386 | * it was stopped due to lack of tx wrbs. | 1378 | * it was stopped due to lack of tx wrbs. |
@@ -1408,7 +1400,7 @@ static int be_poll_tx_mcc(struct napi_struct *napi, int budget) | |||
1408 | 1400 | ||
1409 | be_process_tx(adapter); | 1401 | be_process_tx(adapter); |
1410 | 1402 | ||
1411 | be_process_mcc(&adapter->ctrl); | 1403 | be_process_mcc(adapter); |
1412 | 1404 | ||
1413 | return 1; | 1405 | return 1; |
1414 | } | 1406 | } |
@@ -1420,7 +1412,7 @@ static void be_worker(struct work_struct *work) | |||
1420 | int status; | 1412 | int status; |
1421 | 1413 | ||
1422 | /* Get Stats */ | 1414 | /* Get Stats */ |
1423 | status = be_cmd_get_stats(&adapter->ctrl, &adapter->stats.cmd); | 1415 | status = be_cmd_get_stats(adapter, &adapter->stats.cmd); |
1424 | if (!status) | 1416 | if (!status) |
1425 | netdev_stats_update(adapter); | 1417 | netdev_stats_update(adapter); |
1426 | 1418 | ||
@@ -1454,8 +1446,7 @@ static void be_msix_enable(struct be_adapter *adapter) | |||
1454 | 1446 | ||
1455 | static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) | 1447 | static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) |
1456 | { | 1448 | { |
1457 | return adapter->msix_entries[eq_id - | 1449 | return adapter->msix_entries[eq_id - 8 * adapter->pci_func].vector; |
1458 | 8 * adapter->ctrl.pci_func].vector; | ||
1459 | } | 1450 | } |
1460 | 1451 | ||
1461 | static int be_msix_register(struct be_adapter *adapter) | 1452 | static int be_msix_register(struct be_adapter *adapter) |
@@ -1540,7 +1531,6 @@ done: | |||
1540 | static int be_open(struct net_device *netdev) | 1531 | static int be_open(struct net_device *netdev) |
1541 | { | 1532 | { |
1542 | struct be_adapter *adapter = netdev_priv(netdev); | 1533 | struct be_adapter *adapter = netdev_priv(netdev); |
1543 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1544 | struct be_eq_obj *rx_eq = &adapter->rx_eq; | 1534 | struct be_eq_obj *rx_eq = &adapter->rx_eq; |
1545 | struct be_eq_obj *tx_eq = &adapter->tx_eq; | 1535 | struct be_eq_obj *tx_eq = &adapter->tx_eq; |
1546 | bool link_up; | 1536 | bool link_up; |
@@ -1554,16 +1544,16 @@ static int be_open(struct net_device *netdev) | |||
1554 | 1544 | ||
1555 | be_irq_register(adapter); | 1545 | be_irq_register(adapter); |
1556 | 1546 | ||
1557 | be_intr_set(ctrl, true); | 1547 | be_intr_set(adapter, true); |
1558 | 1548 | ||
1559 | /* The evt queues are created in unarmed state; arm them */ | 1549 | /* The evt queues are created in unarmed state; arm them */ |
1560 | be_eq_notify(ctrl, rx_eq->q.id, true, false, 0); | 1550 | be_eq_notify(adapter, rx_eq->q.id, true, false, 0); |
1561 | be_eq_notify(ctrl, tx_eq->q.id, true, false, 0); | 1551 | be_eq_notify(adapter, tx_eq->q.id, true, false, 0); |
1562 | 1552 | ||
1563 | /* Rx compl queue may be in unarmed state; rearm it */ | 1553 | /* Rx compl queue may be in unarmed state; rearm it */ |
1564 | be_cq_notify(ctrl, adapter->rx_obj.cq.id, true, 0); | 1554 | be_cq_notify(adapter, adapter->rx_obj.cq.id, true, 0); |
1565 | 1555 | ||
1566 | status = be_cmd_link_status_query(ctrl, &link_up); | 1556 | status = be_cmd_link_status_query(adapter, &link_up); |
1567 | if (status) | 1557 | if (status) |
1568 | return status; | 1558 | return status; |
1569 | be_link_status_update(adapter, link_up); | 1559 | be_link_status_update(adapter, link_up); |
@@ -1574,7 +1564,6 @@ static int be_open(struct net_device *netdev) | |||
1574 | 1564 | ||
1575 | static int be_setup(struct be_adapter *adapter) | 1565 | static int be_setup(struct be_adapter *adapter) |
1576 | { | 1566 | { |
1577 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1578 | struct net_device *netdev = adapter->netdev; | 1567 | struct net_device *netdev = adapter->netdev; |
1579 | u32 if_flags; | 1568 | u32 if_flags; |
1580 | int status; | 1569 | int status; |
@@ -1582,7 +1571,7 @@ static int be_setup(struct be_adapter *adapter) | |||
1582 | if_flags = BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PROMISCUOUS | | 1571 | if_flags = BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PROMISCUOUS | |
1583 | BE_IF_FLAGS_MCAST_PROMISCUOUS | BE_IF_FLAGS_UNTAGGED | | 1572 | BE_IF_FLAGS_MCAST_PROMISCUOUS | BE_IF_FLAGS_UNTAGGED | |
1584 | BE_IF_FLAGS_PASS_L3L4_ERRORS; | 1573 | BE_IF_FLAGS_PASS_L3L4_ERRORS; |
1585 | status = be_cmd_if_create(ctrl, if_flags, netdev->dev_addr, | 1574 | status = be_cmd_if_create(adapter, if_flags, netdev->dev_addr, |
1586 | false/* pmac_invalid */, &adapter->if_handle, | 1575 | false/* pmac_invalid */, &adapter->if_handle, |
1587 | &adapter->pmac_id); | 1576 | &adapter->pmac_id); |
1588 | if (status != 0) | 1577 | if (status != 0) |
@@ -1590,7 +1579,7 @@ static int be_setup(struct be_adapter *adapter) | |||
1590 | 1579 | ||
1591 | be_vid_config(netdev); | 1580 | be_vid_config(netdev); |
1592 | 1581 | ||
1593 | status = be_cmd_set_flow_control(ctrl, true, true); | 1582 | status = be_cmd_set_flow_control(adapter, true, true); |
1594 | if (status != 0) | 1583 | if (status != 0) |
1595 | goto if_destroy; | 1584 | goto if_destroy; |
1596 | 1585 | ||
@@ -1613,19 +1602,17 @@ rx_qs_destroy: | |||
1613 | tx_qs_destroy: | 1602 | tx_qs_destroy: |
1614 | be_tx_queues_destroy(adapter); | 1603 | be_tx_queues_destroy(adapter); |
1615 | if_destroy: | 1604 | if_destroy: |
1616 | be_cmd_if_destroy(ctrl, adapter->if_handle); | 1605 | be_cmd_if_destroy(adapter, adapter->if_handle); |
1617 | do_none: | 1606 | do_none: |
1618 | return status; | 1607 | return status; |
1619 | } | 1608 | } |
1620 | 1609 | ||
1621 | static int be_clear(struct be_adapter *adapter) | 1610 | static int be_clear(struct be_adapter *adapter) |
1622 | { | 1611 | { |
1623 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1624 | |||
1625 | be_rx_queues_destroy(adapter); | 1612 | be_rx_queues_destroy(adapter); |
1626 | be_tx_queues_destroy(adapter); | 1613 | be_tx_queues_destroy(adapter); |
1627 | 1614 | ||
1628 | be_cmd_if_destroy(ctrl, adapter->if_handle); | 1615 | be_cmd_if_destroy(adapter, adapter->if_handle); |
1629 | 1616 | ||
1630 | be_mcc_queues_destroy(adapter); | 1617 | be_mcc_queues_destroy(adapter); |
1631 | return 0; | 1618 | return 0; |
@@ -1634,7 +1621,6 @@ static int be_clear(struct be_adapter *adapter) | |||
1634 | static int be_close(struct net_device *netdev) | 1621 | static int be_close(struct net_device *netdev) |
1635 | { | 1622 | { |
1636 | struct be_adapter *adapter = netdev_priv(netdev); | 1623 | struct be_adapter *adapter = netdev_priv(netdev); |
1637 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1638 | struct be_eq_obj *rx_eq = &adapter->rx_eq; | 1624 | struct be_eq_obj *rx_eq = &adapter->rx_eq; |
1639 | struct be_eq_obj *tx_eq = &adapter->tx_eq; | 1625 | struct be_eq_obj *tx_eq = &adapter->tx_eq; |
1640 | int vec; | 1626 | int vec; |
@@ -1645,7 +1631,7 @@ static int be_close(struct net_device *netdev) | |||
1645 | netif_carrier_off(netdev); | 1631 | netif_carrier_off(netdev); |
1646 | adapter->link_up = false; | 1632 | adapter->link_up = false; |
1647 | 1633 | ||
1648 | be_intr_set(ctrl, false); | 1634 | be_intr_set(adapter, false); |
1649 | 1635 | ||
1650 | if (adapter->msix_enabled) { | 1636 | if (adapter->msix_enabled) { |
1651 | vec = be_msix_vec_get(adapter, tx_eq->q.id); | 1637 | vec = be_msix_vec_get(adapter, tx_eq->q.id); |
@@ -1704,13 +1690,12 @@ static void be_netdev_init(struct net_device *netdev) | |||
1704 | 1690 | ||
1705 | static void be_unmap_pci_bars(struct be_adapter *adapter) | 1691 | static void be_unmap_pci_bars(struct be_adapter *adapter) |
1706 | { | 1692 | { |
1707 | struct be_ctrl_info *ctrl = &adapter->ctrl; | 1693 | if (adapter->csr) |
1708 | if (ctrl->csr) | 1694 | iounmap(adapter->csr); |
1709 | iounmap(ctrl->csr); | 1695 | if (adapter->db) |
1710 | if (ctrl->db) | 1696 | iounmap(adapter->db); |
1711 | iounmap(ctrl->db); | 1697 | if (adapter->pcicfg) |
1712 | if (ctrl->pcicfg) | 1698 | iounmap(adapter->pcicfg); |
1713 | iounmap(ctrl->pcicfg); | ||
1714 | } | 1699 | } |
1715 | 1700 | ||
1716 | static int be_map_pci_bars(struct be_adapter *adapter) | 1701 | static int be_map_pci_bars(struct be_adapter *adapter) |
@@ -1721,19 +1706,19 @@ static int be_map_pci_bars(struct be_adapter *adapter) | |||
1721 | pci_resource_len(adapter->pdev, 2)); | 1706 | pci_resource_len(adapter->pdev, 2)); |
1722 | if (addr == NULL) | 1707 | if (addr == NULL) |
1723 | return -ENOMEM; | 1708 | return -ENOMEM; |
1724 | adapter->ctrl.csr = addr; | 1709 | adapter->csr = addr; |
1725 | 1710 | ||
1726 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 4), | 1711 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 4), |
1727 | 128 * 1024); | 1712 | 128 * 1024); |
1728 | if (addr == NULL) | 1713 | if (addr == NULL) |
1729 | goto pci_map_err; | 1714 | goto pci_map_err; |
1730 | adapter->ctrl.db = addr; | 1715 | adapter->db = addr; |
1731 | 1716 | ||
1732 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 1), | 1717 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 1), |
1733 | pci_resource_len(adapter->pdev, 1)); | 1718 | pci_resource_len(adapter->pdev, 1)); |
1734 | if (addr == NULL) | 1719 | if (addr == NULL) |
1735 | goto pci_map_err; | 1720 | goto pci_map_err; |
1736 | adapter->ctrl.pcicfg = addr; | 1721 | adapter->pcicfg = addr; |
1737 | 1722 | ||
1738 | return 0; | 1723 | return 0; |
1739 | pci_map_err: | 1724 | pci_map_err: |
@@ -1744,7 +1729,7 @@ pci_map_err: | |||
1744 | 1729 | ||
1745 | static void be_ctrl_cleanup(struct be_adapter *adapter) | 1730 | static void be_ctrl_cleanup(struct be_adapter *adapter) |
1746 | { | 1731 | { |
1747 | struct be_dma_mem *mem = &adapter->ctrl.mbox_mem_alloced; | 1732 | struct be_dma_mem *mem = &adapter->mbox_mem_alloced; |
1748 | 1733 | ||
1749 | be_unmap_pci_bars(adapter); | 1734 | be_unmap_pci_bars(adapter); |
1750 | 1735 | ||
@@ -1753,12 +1738,10 @@ static void be_ctrl_cleanup(struct be_adapter *adapter) | |||
1753 | mem->va, mem->dma); | 1738 | mem->va, mem->dma); |
1754 | } | 1739 | } |
1755 | 1740 | ||
1756 | /* Initialize the mbox required to send cmds to BE */ | ||
1757 | static int be_ctrl_init(struct be_adapter *adapter) | 1741 | static int be_ctrl_init(struct be_adapter *adapter) |
1758 | { | 1742 | { |
1759 | struct be_ctrl_info *ctrl = &adapter->ctrl; | 1743 | struct be_dma_mem *mbox_mem_alloc = &adapter->mbox_mem_alloced; |
1760 | struct be_dma_mem *mbox_mem_alloc = &ctrl->mbox_mem_alloced; | 1744 | struct be_dma_mem *mbox_mem_align = &adapter->mbox_mem; |
1761 | struct be_dma_mem *mbox_mem_align = &ctrl->mbox_mem; | ||
1762 | int status; | 1745 | int status; |
1763 | u32 val; | 1746 | u32 val; |
1764 | 1747 | ||
@@ -1777,15 +1760,12 @@ static int be_ctrl_init(struct be_adapter *adapter) | |||
1777 | mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16); | 1760 | mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16); |
1778 | mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16); | 1761 | mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16); |
1779 | memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox)); | 1762 | memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox)); |
1780 | spin_lock_init(&ctrl->mbox_lock); | 1763 | spin_lock_init(&adapter->mbox_lock); |
1781 | spin_lock_init(&ctrl->mcc_lock); | 1764 | spin_lock_init(&adapter->mcc_lock); |
1782 | spin_lock_init(&ctrl->mcc_cq_lock); | 1765 | spin_lock_init(&adapter->mcc_cq_lock); |
1783 | |||
1784 | ctrl->async_cb = be_link_status_update; | ||
1785 | ctrl->adapter_ctxt = adapter; | ||
1786 | 1766 | ||
1787 | val = ioread32(ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET); | 1767 | val = ioread32(adapter->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET); |
1788 | ctrl->pci_func = (val >> MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT) & | 1768 | adapter->pci_func = (val >> MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT) & |
1789 | MEMBAR_CTRL_INT_CTRL_PFUNC_MASK; | 1769 | MEMBAR_CTRL_INT_CTRL_PFUNC_MASK; |
1790 | return 0; | 1770 | return 0; |
1791 | } | 1771 | } |
@@ -1840,18 +1820,17 @@ static void __devexit be_remove(struct pci_dev *pdev) | |||
1840 | 1820 | ||
1841 | static int be_hw_up(struct be_adapter *adapter) | 1821 | static int be_hw_up(struct be_adapter *adapter) |
1842 | { | 1822 | { |
1843 | struct be_ctrl_info *ctrl = &adapter->ctrl; | ||
1844 | int status; | 1823 | int status; |
1845 | 1824 | ||
1846 | status = be_cmd_POST(ctrl); | 1825 | status = be_cmd_POST(adapter); |
1847 | if (status) | 1826 | if (status) |
1848 | return status; | 1827 | return status; |
1849 | 1828 | ||
1850 | status = be_cmd_get_fw_ver(ctrl, adapter->fw_ver); | 1829 | status = be_cmd_get_fw_ver(adapter, adapter->fw_ver); |
1851 | if (status) | 1830 | if (status) |
1852 | return status; | 1831 | return status; |
1853 | 1832 | ||
1854 | status = be_cmd_query_fw_cfg(ctrl, &adapter->port_num); | 1833 | status = be_cmd_query_fw_cfg(adapter, &adapter->port_num); |
1855 | return status; | 1834 | return status; |
1856 | } | 1835 | } |
1857 | 1836 | ||
@@ -1861,7 +1840,6 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
1861 | int status = 0; | 1840 | int status = 0; |
1862 | struct be_adapter *adapter; | 1841 | struct be_adapter *adapter; |
1863 | struct net_device *netdev; | 1842 | struct net_device *netdev; |
1864 | struct be_ctrl_info *ctrl; | ||
1865 | u8 mac[ETH_ALEN]; | 1843 | u8 mac[ETH_ALEN]; |
1866 | 1844 | ||
1867 | status = pci_enable_device(pdev); | 1845 | status = pci_enable_device(pdev); |
@@ -1896,7 +1874,6 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
1896 | } | 1874 | } |
1897 | } | 1875 | } |
1898 | 1876 | ||
1899 | ctrl = &adapter->ctrl; | ||
1900 | status = be_ctrl_init(adapter); | 1877 | status = be_ctrl_init(adapter); |
1901 | if (status) | 1878 | if (status) |
1902 | goto free_netdev; | 1879 | goto free_netdev; |
@@ -1909,7 +1886,7 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
1909 | if (status) | 1886 | if (status) |
1910 | goto stats_clean; | 1887 | goto stats_clean; |
1911 | 1888 | ||
1912 | status = be_cmd_mac_addr_query(ctrl, mac, MAC_ADDRESS_TYPE_NETWORK, | 1889 | status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK, |
1913 | true /* permanent */, 0); | 1890 | true /* permanent */, 0); |
1914 | if (status) | 1891 | if (status) |
1915 | goto stats_clean; | 1892 | goto stats_clean; |