Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sli4_iscsi.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34 \defgroup sli_iscsi SLI-4 iSCSI APIs
35  */
36 
37 /**
38  * @file
39  * Implementation of iSCSI SLI-4 functions
40  */
41 
42 #include "ocs_os.h"
43 #include "ocs_hal.h"
44 #include "sli4_iscsi.h"
45 
46 #if defined(OCS_INCLUDE_DEBUG)
47 #include "ocs_debug.h"
48 #endif
49 
50 extern const char *SLI_QNAME[];
51 
52 /**
53  * @ingroup sli_iscsi
54  * @brief write a COMMON_ISCSI_NTWK_IFACE_CREATE command
55  *
56  * @param sli4 SLI context
57  * @param buf destination buffer for the command
58  * @param size buffer size in bytes
59  * @param tag command tag
60  * @param vlan The vlan/priority
61  *
62  * @return number of bytes written
63  */
64 int32_t
66  size_t size, uint64_t tag, uint32_t vlan)
67 {
69  uint32_t cmd_off = 0;
70  uint32_t payload_size;
71 
72  /* Payload length must accomodate both request and response */
73  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_iface_create_t),
75 
76  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
77  NULL);
78 
79  req = (sli4_req_common_iscsi_ntwk_iface_create_t*)((uint8_t *)buf + cmd_off);
80 
83  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
84  req->vlan = vlan;
85 
86  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_iface_create_t));
87 }
88 
89 
90 /**
91  * @ingroup sli_iscsi
92  * @brief write a COMMON_ISCSI_NTWK_IFACE_CREATE command
93  *
94  * @param sli4 SLI context
95  * @param buf destination buffer for the command
96  * @param size buffer size in bytes
97  * @param tag command tag
98  * @param iface the portal interface handle
99  *
100  * @return number of bytes written
101  */
102 int32_t
104  size_t size, uint64_t tag, uint32_t iface)
105 {
107  uint32_t cmd_off = 0;
108  uint32_t payload_size;
109 
110  /* Payload length must accomodate both request and response */
111  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_iface_delete_t),
113 
114  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
115  NULL);
116 
117  req = (sli4_req_common_iscsi_ntwk_iface_delete_t*)((uint8_t *)buf + cmd_off);
118 
121  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
122  req->iface = iface;
123 
124  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_iface_create_t));
125 }
126 
127 /**
128  * @ingroup sli_iscsi
129  * @brief write a COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR command
130  *
131  * @param sli4 SLI context
132  * @param buf destination buffer for the command
133  * @param size buffer size in bytes
134  * @param tag command tag
135  * @param iface the portal interface handle
136  * @param isv4 set to non-zero for IPv4, otherwise IPv6
137  * @param retries the number of retry attempts
138  *
139  * @return number of bytes written
140  */
141 int32_t
143  size_t size, uint64_t tag,
144  uint32_t iface, uint8_t isv4,
145  uint32_t retries)
146 {
148  uint32_t cmd_off = 0;
149  uint32_t payload_size;
150 
151  /* Payload length must accomodate both request and response */
153  sizeof(sli4_res_hdr_t));
154 
155  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
156  NULL);
157 
159  ((uint8_t *)buf + cmd_off);
160 
163  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
164  req->iface = iface;
165  req->ip_type = (isv4 ? 0x01 : 0x10);
166  req->flags = 0x02; /* non-blocking, do not save in flash */
167  req->retry_count = retries;
168 
170 }
171 
172 
173 /**
174  * @ingroup sli_iscsi
175  * @brief write a COMMON_ISCSI_NTWK_RELEASE_STATELESS_IP_ADDR command
176  *
177  * @param sli4 SLI context
178  * @param buf destination buffer for the command
179  * @param size buffer size in bytes
180  * @param tag command tag
181  * @param iface the portal interface handle
182  * @param isv4 set to non-zero for IPv4, otherwise IPv6
183  *
184  * @return number of bytes written
185  */
186 int32_t
188  size_t size, uint64_t tag,
189  uint32_t iface, uint8_t isv4)
190 {
192  uint32_t cmd_off = 0;
193  uint32_t payload_size;
194 
195  /* Payload length must accomodate both request and response */
197  sizeof(sli4_res_hdr_t));
198 
199  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
200  NULL);
201 
203  ((uint8_t *)buf + cmd_off);
204 
207  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
208  req->iface = iface;
209  req->ip_type = (isv4 ? 0x01 : 0x10);
210 
212 }
213 
214 /**
215  * @ingroup sli_iscsi
216  * @brief write a COMMON_ISCSI_NTWK_DISCOVER_ISNS_SERVER command
217  *
218  * @param sli4 SLI context
219  * @param buf destination buffer for the command
220  * @param size buffer size in bytes
221  * @param tag command tag
222  * @param iface the portal interface handle
223  * @param retries the number of retry attempts
224  *
225  * @return number of bytes written
226  */
227 int32_t
229  size_t size, uint64_t tag,
230  uint32_t iface, uint32_t retries)
231 {
233  uint32_t cmd_off = 0;
234  uint32_t payload_size;
235 
236  /* Payload length must accomodate both request and response */
237  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_discover_isns_server_t),
238  sizeof(sli4_res_hdr_t));
239 
240  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
241  NULL);
242 
244  ((uint8_t *)buf + cmd_off);
245 
248  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
249  req->iface = iface;
250  req->retry_count = retries;
251  req->flags = 0x02; /* non-blocking, do not save in flash */
252 
253  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_discover_isns_server_t));
254 }
255 
256 /**
257  * @ingroup sli_iscsi
258  * @brief write a COMMON_ISCSI_NTWK_DISCOVERED_ISNS_SERVERS command
259  *
260  * @param sli4 SLI context
261  * @param buf destination buffer for the command
262  * @param size buffer size in bytes
263  * @param tag command tag
264  * @param iface the portal interface handle
265  *
266  * @return number of bytes written
267  */
268 int32_t
270  size_t size, uint64_t tag,
271  uint32_t iface)
272 {
274  uint32_t cmd_off = 0;
275  uint32_t payload_size;
276 
277  /* Payload length must accomodate both request and response */
278  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_discovered_isns_servers_t),
280 
281  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
282  NULL);
283 
285  ((uint8_t *)buf + cmd_off);
286 
289  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
290  req->iface = iface;
291 
292  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_discover_isns_server_t));
293 }
294 
295 
296 /**
297  * @ingroup sli_iscsi
298  * @brief Converts the IP address type field to the SLI4 equivalent value.
299  *
300  * @param ip_type the HAL enum to convert.
301  *
302  * @return the SLI4 IP type
303  */
304 uint8_t
306 {
307  uint8_t rval = 0;
308  switch(ip_type) {
309  case OCS_HAL_IP_TYPE_V4:
310  rval = 1;
311  break;
313  rval = 5;
314  break;
315  case OCS_HAL_IP_TYPE_V6:
316  rval = 0x10;
317  break;
319  rval = 0x90;
320  break;
322  rval = 0x30;
323  break;
325  rval = 0x50;
326  break;
327  default:
328  break;
329  }
330  return rval;
331 }
332 
333 /**
334  * @ingroup sli_iscsi
335  * @brief Converts the SLI4 IP address type field to the HAL equivalent value.
336  *
337  * @param ip_type the SLI4 value to convert.
338  *
339  * @return The HAL IP type
340  */
343 {
344  ocs_hal_ip_type_e rval = 0;
345  switch(ip_type) {
346  case 0x01:
347  case 0x03:
348  rval = OCS_HAL_IP_TYPE_V4;
349  break;
350  case 0x05:
352  break;
353  case 0x10:
354  rval = OCS_HAL_IP_TYPE_V6;
355  break;
356  case 0x30:
358  break;
359  case 0x50:
361  break;
362  case 0x90:
364  break;
365  default:
366  break;
367  }
368  return rval;
369 }
370 
371 /**
372  * @ingroup sli_iscsi
373  * @brief write a COMMON_ISCSI_NTWK_SET_ROUTE_TABLE command
374  *
375  * @param sli4 SLI context
376  * @param buf destination buffer for the command
377  * @param size buffer size in bytes
378  * @param tag command tag
379  * @param isadd set to non-zero for adding, otherwise removing
380  * @param ip_sub the IP address and subnet to add/remove
381  * @param gateway the IP address of the gateway to add/remove
382  *
383  * @return number of bytes written
384  */
385 int32_t sli_cmd_iscsi_common_set_route_table(sli4_t *sli4, void *buf, size_t size,
386  uint64_t tag, uint8_t isadd,
387  ocs_hal_ip_address_subnet_t *hal_ipsub,
388  ocs_hal_ip_address_t *hal_gateway,
389  ocs_dma_t *dma)
390 {
392  uint32_t cmd_off = 0;
393  uint32_t payload_size;
394 
395  payload_size = dma->size;
396 
397  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size, dma);
399 
400  ocs_memset(req, 0, sizeof(sli4_req_common_iscsi_ntwk_set_route_table_t));
403  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
405  req->entry[0].ip_sub.struct_size = sizeof(sli4_ip_addr_subnet_t);
407  ocs_memcpy(req->entry[0].ip_sub.ip_addr, hal_ipsub->ip_address, 16);
408  ocs_memcpy(req->entry[0].ip_sub.subnet, hal_ipsub->subnet, 16);
409  req->entry[0].gateway.struct_size = sizeof(sli4_ip_addr_t);
411  ocs_memcpy(req->entry[0].gateway.ip_addr, hal_gateway->ip_address, 16);
412 
413  return (cmd_off + sizeof(sli4_req_common_iscsi_ntwk_set_route_table_t));
414 }
415 
416 /**
417  * @ingroup sli_iscsi
418  * @brief write a COMMON_ISCSI_NTWK_GET_ROUTE_TABLE command
419  *
420  * @param sli4 SLI context
421  * @param buf destination buffer for the command
422  * @param size buffer size in bytes
423  * @param tag command tag
424  *
425  * @return number of bytes written
426  */
427 int32_t sli_cmd_iscsi_common_get_route_table(sli4_t *sli4, void *buf, size_t size,
428  uint64_t tag, ocs_dma_t *dma)
429 {
431  uint32_t cmd_off = 0;
432  uint32_t payload_size;
433 
434  payload_size = dma->size;
435 
436  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size, dma);
438 
439  ocs_memset(req, 0, sizeof(sli4_req_common_iscsi_ntwk_set_route_table_t));
442  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
443 
444  return (cmd_off + sizeof(sli4_req_common_iscsi_ntwk_set_route_table_t));
445 }
446 
447 /**
448  * @ingroup sli_iscsi
449  * @brief write a COMMON_ISCSI_NTWK_MODIFY_IP_ADDR command
450  *
451  * @param sli4 SLI context
452  * @param buf destination buffer for the command
453  * @param size buffer size in bytes
454  * @param tag command tag
455  * @param iface the portal interface handle
456  * @param isadd set to non-zero for adding an address, otherwise removing
457  * @param ipaddr the IP address and subnet mask
458  *
459  * @return number of bytes written
460  */
461 int32_t
463  size_t size, uint64_t tag,
464  uint32_t iface, uint8_t isadd,
466 {
468  uint32_t cmd_off = 0;
469  uint32_t payload_size;
470 
471  /* Payload length must accomodate both request and response */
472  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_modify_ip_addr_t),
473  sizeof(sli4_res_hdr_t));
474 
475  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
476  NULL);
477 
479  ((uint8_t *)buf + cmd_off);
480 
483  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
484  req->record_count = 1;
485  req->action = (isadd ? 1 : 2);
486  req->iface = iface;
487  req->ip_addr_subnet.struct_size = 40;
489  ocs_memcpy(req->ip_addr_subnet.ip_addr, ipaddr->ip_address, 16);
490  ocs_memcpy(req->ip_addr_subnet.subnet, ipaddr->subnet, 16);
491 
492  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_modify_ip_addr_t));
493 }
494 
495 
496 /**
497  * @ingroup sli_iscsi
498  * @brief write a COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY command
499  *
500  * @param sli4 SLI context
501  * @param buf destination buffer for the command
502  * @param size buffer size in bytes
503  * @param tag command tag
504  * @param isv4 set to non-zero for IPv4, otherwise IPv6
505  *
506  * @return number of bytes written
507  */
508 int32_t
510  size_t size, uint64_t tag,
511  uint8_t isv4)
512 {
514  uint32_t cmd_off = 0;
515  uint32_t payload_size;
516 
517  /* Payload length must accomodate both request and response */
518  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_get_default_gateway_t),
520 
521  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
522  NULL);
523 
525  ((uint8_t *)buf + cmd_off);
526 
529  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
530  req->ip_type = (isv4 ? 0x01 : 0x10);
531 
532  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_get_default_gateway_t));
533 }
534 
535 /**
536  * @ingroup sli_iscsi
537  * @brief write a COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY command
538  *
539  * @param sli4 SLI context
540  * @param buf destination buffer for the command
541  * @param size buffer size in bytes
542  * @param tag command tag
543  * @param isadd set to non-zero for adding, otherwise removing
544  * @param gateway the IP address of the gateway to add/remove
545  *
546  * @return number of bytes written
547  */
548 int32_t
550  size_t size, uint64_t tag,
551  uint8_t isadd,
552  ocs_hal_ip_address_t *gateway)
553 {
555  uint32_t cmd_off = 0;
556  uint32_t payload_size;
557 
558  /* Payload length must accomodate both request and response */
559  payload_size = max(sizeof(sli4_req_common_iscsi_ntwk_modify_default_gateway_t),
560  sizeof(sli4_res_hdr_t));
561 
562  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
563  NULL);
564 
566  ((uint8_t *)buf + cmd_off);
567 
570  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
571  req->action = (isadd ? 1 : 2);
572  req->gateway.struct_size = 24;
574  ocs_memcpy(req->gateway.ip_addr, gateway->ip_address, 16);
575 
576  return(cmd_off + sizeof(sli4_req_common_iscsi_ntwk_modify_default_gateway_t));
577 }
578 
579 
580 /**
581  * @ingroup sli_iscsi
582  * @brief write a COMMON_ISCSI_NTWK_GET_ALL_IF_ID command
583  *
584  * @param sli4 SLI context
585  * @param buf destination buffer for the command
586  * @param size buffer size in bytes
587  * @param tag command tag
588  *
589  * @return number of bytes written
590  */
592  size_t size, uint64_t tag)
593 {
595  uint32_t cmd_off = 0;
596  uint32_t payload_size;
597 
598  /* Payload length must accomodate both request and response */
599  payload_size = max(sizeof(sli4_req_iscsi_ntwk_get_all_if_id_t),
601 
602  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
603  NULL);
604 
605  req = (sli4_req_iscsi_ntwk_get_all_if_id_t*)((uint8_t *)buf + cmd_off);
606 
609  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
610 
611  return(cmd_off + sizeof(sli4_req_iscsi_ntwk_get_all_if_id_t));
612 }
613 
614 
615 /**
616  * @ingroup sli_iscsi
617  * @brief write a COMMON_ISCSI_NTWK_GET_IF_INFO command
618  *
619  * @param sli4 SLI context
620  * @param buf destination buffer for the command
621  * @param size buffer size in bytes
622  * @param tag command tag
623  * @param iface the interface handle to retrieve information
624  * @param isv4 set to non-zero for IPv4, otherwise IPv6
625  *
626  * @return number of bytes written
627  */
628 int32_t
630  size_t size, uint64_t tag,
631  uint32_t iface, uint8_t isv4)
632 {
634  uint32_t cmd_off = 0;
635  uint32_t payload_size;
636 
637  /* Payload length must accomodate both request and response */
638  payload_size = max(sizeof(sli4_req_iscsi_ntwk_get_if_info_t),
640 
641  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
642  NULL);
643 
644  req = (sli4_req_iscsi_ntwk_get_if_info_t*)((uint8_t *)buf + cmd_off);
645 
648  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
649  req->iface = iface;
650  req->ip_type = (isv4 ? 0x01 : 0x10);
651 
652  return(cmd_off + sizeof(sli4_req_iscsi_ntwk_get_if_info_t));
653 }
654 
655 
656 /**
657  * @ingroup sli_iscsi
658  * @brief write a COMMON_ISCSI_CLEANUP (version 0) command
659  *
660  * @param sli4 SLI context
661  * @param buf destination buffer for the command
662  * @param size buffer size in bytes
663  * @param tag command tag
664  * @param ulp_no the Chute number TBD
665  * @param hdrq_id the receive header queue assigned to this connection
666  * @param dataq_id the receive data queue assigned to this connection
667  *
668  * @return number of bytes written
669  */
670 int32_t
672  size_t size, uint64_t tag,
673  uint16_t ulp_no,
674  uint8_t hdrq_id,
675  uint8_t dataq_id)
676 {
677  sli4_req_iscsi_cleanup_v0_t *req = NULL;
678  uint32_t cmd_off = 0;
679  uint32_t payload_size;
680 
681  /* Payload length must accomodate both request and response */
682  payload_size = max(sizeof(sli4_req_iscsi_cleanup_v0_t),
683  sizeof(sli4_res_hdr_t));
684 
685  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
686  NULL);
687 
688  req = (sli4_req_iscsi_cleanup_v0_t*)((uint8_t *)buf + cmd_off);
689 
692  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
693  req->ulp = ulp_no;
694  req->hdr_ring_id = hdrq_id;
695  req->data_ring_id = dataq_id;
696 
697  return(cmd_off + sizeof(sli4_req_iscsi_cleanup_v0_t));
698 }
699 
700 
701 /**
702  * @ingroup sli_iscsi
703  * @brief write a COMMON_ISCSI_CLEANUP (version 1) command
704  *
705  * @param sli4 SLI context
706  * @param buf destination buffer for the command
707  * @param size buffer size in bytes
708  * @param tag command tag
709  * @param ulp_no the Chute number TBD
710  * @param hdrq_id the receive header queue assigned to this connection
711  * @param dataq_id the receive data queue assigned to this connection
712  *
713  * @return number of bytes written
714  */
715 int32_t
717  size_t size, uint64_t tag,
718  uint16_t ulp_no,
719  uint16_t hdrq_id,
720  uint16_t dataq_id)
721 {
722  sli4_req_iscsi_cleanup_v1_t *req = NULL;
723  uint32_t cmd_off = 0;
724  uint32_t payload_size;
725 
726  /* Payload length must accomodate both request and response */
727  payload_size = max(sizeof(sli4_req_iscsi_cleanup_v1_t),
728  sizeof(sli4_res_hdr_t));
729 
730  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
731  NULL);
732 
733  req = (sli4_req_iscsi_cleanup_v1_t*)((uint8_t *)buf + cmd_off);
734 
737  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
738  req->hdr.version = 1;
739  req->ulp = ulp_no;
740  req->hdr_ring_id = hdrq_id;
741  req->data_ring_id = dataq_id;
742 
743  return(cmd_off + sizeof(sli4_req_iscsi_cleanup_v1_t));
744 }
745 
746 
747 /**
748  * @ingroup sli_iscsi
749  * @brief write a COMMON_ISCSI_SET_FRAGNUM_BITS command
750  *
751  * @param sli4 SLI context
752  * @param buf destination buffer for the command
753  * @param size buffer size in bytes
754  * @param tag command tag
755  * @param num_bits the number of bits for SGEs
756  *
757  * @return number of bytes written
758  */
759 static int32_t
761  size_t size, uint64_t tag,
762  uint32_t num_bits)
763 {
764  sli4_req_iscsi_set_frag_bits_t *req = NULL;
765  uint32_t cmd_off = 0;
766  uint32_t payload_size;
767 
768  /* Payload length must accomodate both request and response */
769  payload_size = max(sizeof(sli4_req_iscsi_set_frag_bits_t),
770  sizeof(sli4_res_hdr_t));
771 
772  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
773  NULL);
774 
775  req = (sli4_req_iscsi_set_frag_bits_t*)((uint8_t *)buf + cmd_off);
776 
779  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
780  req->num_bits = num_bits;
781 
782  return(cmd_off + sizeof(sli4_req_iscsi_set_frag_bits_t));
783 }
784 
785 
786 /**
787  * @ingroup sli_iscsi
788  * @brief write a ISCSI_TGT_START_LISTEN_SERVER command
789  *
790  * @param sli4 SLI context
791  * @param buf destination buffer for the command
792  * @param size buffer size in bytes
793  * @param tag command tag
794  * @param ipaddr the IP address
795  * @param tcp_port the TCP port number
796  *
797  * @return number of bytes written
798  */
799 int32_t
801  size_t size, uint64_t tag,
802  ocs_hal_ip_address_t *ipaddr,
803  uint32_t tcp_port)
804 {
806  uint32_t cmd_off = 0;
807  uint32_t payload_size;
808 
809  /* Payload length must accomodate both request and response */
810  payload_size = max(sizeof(sli4_req_iscsi_tgt_start_listen_server_t),
811  sizeof(sli4_res_hdr_t));
812 
813  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
814  NULL);
815 
817  ((uint8_t *)buf + cmd_off);
818 
821  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
822  req->ipaddr.struct_size = 24;
824  ocs_memcpy(req->ipaddr.ip_addr, ipaddr->ip_address, 16);
825  req->tcp_port = tcp_port;
826 
827  return(cmd_off + sizeof(sli4_req_iscsi_tgt_start_listen_server_t));
828 }
829 
830 
831 /**
832  * @ingroup sli_iscsi
833  * @brief write a ISCSI_TGT_STOP_LISTEN_SERVER command
834  *
835  * @param sli4 SLI context
836  * @param buf destination buffer for the command
837  * @param size buffer size in bytes
838  * @param tag command tag
839  * @param ipaddr the IP address
840  * @param tcp_port the TCP port number
841  *
842  * @return number of bytes written
843  */
844 int32_t
846  size_t size, uint64_t tag,
847  ocs_hal_ip_address_t *ipaddr,
848  uint32_t tcp_port)
849 {
851  uint32_t cmd_off = 0;
852  uint32_t payload_size;
853 
854  /* Payload length must accomodate both request and response */
855  payload_size = max(sizeof(sli4_req_iscsi_tgt_stop_listen_server_t),
856  sizeof(sli4_res_hdr_t));
857 
858  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
859  NULL);
860 
862  ((uint8_t *)buf + cmd_off);
863 
866  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
867  req->ipaddr.struct_size = 24;
869  ocs_memcpy(req->ipaddr.ip_addr, ipaddr->ip_address, 16);
870  req->tcp_port = tcp_port;
871 
872  return(cmd_off + sizeof(sli4_req_iscsi_tgt_stop_listen_server_t));
873 }
874 
875 
876 /**
877  * @ingroup sli_iscsi
878  * @brief write a ISCSI_TGT_GET_CONNECTION_INFO command
879  *
880  * @param sli4 SLI context
881  * @param buf destination buffer for the command
882  * @param size buffer size in bytes
883  * @param tag command tag
884  * @param conn_hdl the connection handle
885  *
886  * @return number of bytes written
887  */
888 int32_t
890  size_t size, uint64_t tag,
891  uint32_t conn_hdl)
892 {
894  uint32_t cmd_off = 0;
895  uint32_t payload_size;
896 
897  /* Payload length must accomodate both request and response */
898  payload_size = max(sizeof(sli4_req_iscsi_tgt_get_connection_info_t),
900 
901  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
902  NULL);
903 
905  ((uint8_t *)buf + cmd_off);
906 
909  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
910  req->conn_handle = conn_hdl;
911 
912  return(cmd_off + sizeof(sli4_req_iscsi_tgt_get_connection_info_t));
913 }
914 
915 
916 /**
917  * @ingroup sli_iscsi
918  * @brief write a ISCSI_TGT_CONNECTION_REJECT command
919  *
920  * @param sli4 SLI context
921  * @param buf destination buffer for the command
922  * @param size buffer size in bytes
923  * @param tag command tag
924  * @param conn_hdl the connection ID
925  *
926  * @return number of bytes written
927  */
928 int32_t
930  size_t size, uint64_t tag,
931  uint32_t conn_hdl)
932 {
934  uint32_t cmd_off = 0;
935  uint32_t payload_size;
936 
937  /* Payload length must accomodate both request and response */
938  payload_size = max(sizeof(sli4_req_iscsi_tgt_connection_reject_t),
939  sizeof(sli4_res_hdr_t));
940 
941  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
942  NULL);
943 
945  ((uint8_t *)buf + cmd_off);
946 
949  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
950  req->conn_handle = conn_hdl;
951 
952  return(cmd_off + sizeof(sli4_req_iscsi_tgt_connection_reject_t));
953 }
954 
955 
956 /**
957  * @ingroup sli_iscsi
958  * @brief write a ISCSI_TGT_OFFLOAD_CONNECTION command (version 0)
959  *
960  * @param sli4 SLI context
961  * @param buf destination buffer for the command
962  * @param size buffer size in bytes
963  * @param tag command tag
964  * @param conn_hdl the connection handle
965  * @param tcp_window_size the TCP window advertised
966  * @param ulp_no the Chute number TBD
967  * @param wq_id the work queue assigned to this connection
968  * @param cq_id the completion queue assigned to this connection
969  * @param hdrq_id the receive header queue assigned to this connection
970  * @param dataq_id the receive data queue assigned to this connection
971  * @param nrs set to 1 if the driver will not free resources on the
972  * invalidate_commands completion and will wait for each IO
973  * completion. (Skyhawk only)
974  * @param lgn_options the target login options for the connection
975  *
976  * @return number of bytes written
977  */
978 int32_t
980  size_t size, uint64_t tag,
981  uint32_t conn_hdl,
982  uint32_t tcp_window_size,
983  uint16_t ulp_no,
984  uint16_t wq_id,
985  uint16_t cq_id,
986  uint8_t hdrq_id,
987  uint8_t dataq_id,
988  uint8_t nrs,
989  ocs_hal_target_login_options_t *lgn_options)
990 {
992  uint32_t cmd_off = 0;
993  uint32_t payload_size;
995  ocs_session_login_options_t *hal_sess;
996 
997  /* Payload length must accomodate both request and response */
998  payload_size = max(sizeof(sli4_req_iscsi_tgt_offload_connection_v0_t),
999  sizeof(sli4_res_hdr_t));
1000 
1001  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1002  NULL);
1003 
1005  ((uint8_t *)buf + cmd_off);
1006 
1009  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1010  req->conn_handle = conn_hdl;
1011  req->cid = wq_id;
1012  req->cq_id = cq_id;
1013  req->hdr_id = hdrq_id;
1014  req->data_id = dataq_id;
1015  req->ulp_number = ulp_no;
1016  req->tcp_window = tcp_window_size;
1017 
1018  if (sli4->features.tcp_offload_nrs) {
1019  req->nrs = nrs;
1020  }
1021 
1022  req->login_options.data_digest = lgn_options->data_digest;
1023  req->login_options.hdr_digest = lgn_options->hdr_digest;
1024  req->login_options.max_rcv_dsl = lgn_options->max_rcv_dsl;
1025 
1026  session = &req->login_options.session_options;
1027  hal_sess = &lgn_options->session_options;
1028  session->flags =
1029  ((hal_sess->initial_r2t ? SLI_LOGIN_FLAG_INITIAL_R2T : 0) |
1030  (hal_sess->immediate_data ? SLI_LOGIN_FLAG_IMMEDIATE_DATA : 0) |
1033 
1034  session->error_recovery_level = hal_sess->error_recovery_level;
1035  session->first_burst = hal_sess->first_burst;
1036  session->max_burst = hal_sess->max_burst;
1037  session->max_connections = hal_sess->max_connections;
1038  session->max_r2t = hal_sess->max_r2t;
1039  session->def_time_to_wait = hal_sess->def_time_to_wait;
1040  session->def_time_to_retain = hal_sess->def_time_to_retain;
1041 
1042  return(cmd_off + sizeof(sli4_req_iscsi_tgt_offload_connection_v0_t));
1043 }
1044 
1045 
1046 /**
1047  * @ingroup sli_iscsi
1048  * @brief write a ISCSI_TGT_OFFLOAD_CONNECTION command (version 1)
1049  *
1050  * @param sli4 SLI context
1051  * @param buf destination buffer for the command
1052  * @param size buffer size in bytes
1053  * @param tag command tag
1054  * @param conn_hdl the connection handle
1055  * @param tcp_window_size the TCP window advertised
1056  * @param ulp_no the Chute number TBD
1057  * @param wq_id the work queue assigned to this connection
1058  * @param cq_id the completion queue assigned to this connection
1059  * @param hdrq_id the receive header queue assigned to this connection
1060  * @param dataq_id the receive data queue assigned to this connection
1061  * @param nrs set to 1 if the driver will not free resources on the
1062  * invalidate_commands completion and will wait for each IO
1063  * completion. (Skyhawk only)
1064  * @param lgn_options the target login options for the connection
1065  *
1066  * @return number of bytes written
1067  */
1068 int32_t
1070  size_t size, uint64_t tag,
1071  uint32_t conn_hdl,
1072  uint32_t tcp_window_size,
1073  uint16_t ulp_no,
1074  uint16_t wq_id,
1075  uint16_t cq_id,
1076  uint16_t hdrq_id,
1077  uint16_t dataq_id,
1078  uint8_t nrs,
1079  ocs_hal_target_login_options_t *lgn_options)
1080 {
1082  uint32_t cmd_off = 0;
1083  uint32_t payload_size;
1085  ocs_session_login_options_t *hal_sess;
1086 
1087  /* Payload length must accomodate both request and response */
1088  payload_size = max(sizeof(sli4_req_iscsi_tgt_offload_connection_v1_t),
1089  sizeof(sli4_res_hdr_t));
1090 
1091  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1092  NULL);
1093 
1095  ((uint8_t *)buf + cmd_off);
1096 
1099  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1100  req->hdr.version = 1;
1101  req->conn_handle = conn_hdl;
1102  req->cid = wq_id;
1103  req->cq_id = cq_id;
1104  req->hdr_id = hdrq_id;
1105  req->data_id = dataq_id;
1106  req->ulp_number = ulp_no;
1107  req->tcp_window = tcp_window_size;
1108 
1109  if (sli4->features.tcp_offload_nrs) {
1110  req->nrs = nrs;
1111  }
1112 
1113  req->login_options.data_digest = lgn_options->data_digest;
1114  req->login_options.hdr_digest = lgn_options->hdr_digest;
1115  req->login_options.max_rcv_dsl = lgn_options->max_rcv_dsl;
1116 
1117  session = &req->login_options.session_options;
1118  hal_sess = &lgn_options->session_options;
1119  session->flags =
1120  ((hal_sess->initial_r2t ? SLI_LOGIN_FLAG_INITIAL_R2T : 0) |
1121  (hal_sess->immediate_data ? SLI_LOGIN_FLAG_IMMEDIATE_DATA : 0) |
1124 
1125  session->error_recovery_level = hal_sess->error_recovery_level;
1126  session->first_burst = hal_sess->first_burst;
1127  session->max_burst = hal_sess->max_burst;
1128  session->max_connections = hal_sess->max_connections;
1129  session->max_r2t = hal_sess->max_r2t;
1130  session->def_time_to_wait = hal_sess->def_time_to_wait;
1131  session->def_time_to_retain = hal_sess->def_time_to_retain;
1132 
1133  return(cmd_off + sizeof(sli4_req_iscsi_tgt_offload_connection_v1_t));
1134 }
1135 
1136 
1137 /**
1138  * @ingroup sli_iscsi
1139  * @brief write a ISCSI_TGT_INVALIDATE_CONNECTION command
1140  *
1141  * @param sli4 SLI context
1142  * @param buf destination buffer for the command
1143  * @param size buffer size in bytes
1144  * @param tag command tag
1145  * @param conn_hdl the connection ID
1146  * @param cid the wq_id assigned with the connection
1147  * @param sendRst non-zero sends a TCP reset on the connection.
1148  *
1149  * @return number of bytes written
1150  */
1151 int32_t
1153  size_t size, uint64_t tag,
1154  uint32_t conn_hdl,
1155  uint16_t cid,
1156  uint8_t sendRst)
1157 {
1159  uint32_t cmd_off = 0;
1160  uint32_t payload_size;
1161 
1162  /* Payload length must accomodate both request and response */
1163  payload_size = max(sizeof(sli4_req_iscsi_tgt_invalidate_connection_t),
1164  sizeof(sli4_res_hdr_t));
1165 
1166  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1167  NULL);
1168 
1170  ((uint8_t *)buf + cmd_off);
1171 
1174  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1175  req->conn_handle = conn_hdl;
1176  req->cid = cid;
1177  req->cleanup_type = (sendRst ? 2 : 1);
1178 
1179  return(cmd_off + sizeof(sli4_req_iscsi_tgt_invalidate_connection_t));
1180 }
1181 
1182 
1183 /**
1184  * @ingroup sli_iscsi
1185  * @brief write a ISCSI_TGT_START_ESI_LISTEN command
1186  *
1187  * @param sli4 SLI context
1188  * @param buf destination buffer for the command
1189  * @param size buffer size in bytes
1190  * @param tag command tag
1191  * @param ipaddr the IP address
1192  * @param tcp_port the TCP port number
1193  *
1194  * @return number of bytes written
1195  */
1196 int32_t
1198  size_t size, uint64_t tag,
1199  ocs_hal_ip_address_t *ipaddr,
1200  uint32_t tcp_port)
1201 {
1203  uint32_t cmd_off = 0;
1204  uint32_t payload_size;
1205 
1206  /* Payload length must accomodate both request and response */
1207  payload_size = max(sizeof(sli4_req_iscsi_tgt_start_esi_listen_t),
1208  sizeof(sli4_res_hdr_t));
1209 
1210  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1211  NULL);
1212 
1214  ((uint8_t *)buf + cmd_off);
1215 
1218  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1219  req->ipaddr.struct_size = 24;
1221  ocs_memcpy(req->ipaddr.ip_addr, ipaddr->ip_address, 16);
1222  req->tcp_port = tcp_port;
1223 
1224  return(cmd_off + sizeof(sli4_req_iscsi_tgt_start_esi_listen_t));
1225 }
1226 
1227 
1228 /**
1229  * @ingroup sli_iscsi
1230  * @brief write a ISCSI_TGT_STOP_ESI_LISTEN command
1231  *
1232  * @param sli4 SLI context
1233  * @param buf destination buffer for the command
1234  * @param size buffer size in bytes
1235  * @param tag command tag
1236  * @param ipaddr the IP address
1237  * @param tcp_port the TCP port number
1238  *
1239  * @return number of bytes written
1240  */
1241 int32_t
1243  size_t size, uint64_t tag,
1244  ocs_hal_ip_address_t *ipaddr,
1245  uint32_t tcp_port)
1246 {
1248  uint32_t cmd_off = 0;
1249  uint32_t payload_size;
1250 
1251  /* Payload length must accomodate both request and response */
1252  payload_size = max(sizeof(sli4_req_iscsi_tgt_stop_esi_listen_t),
1253  sizeof(sli4_res_hdr_t));
1254 
1255  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1256  NULL);
1257 
1259  ((uint8_t *)buf + cmd_off);
1260 
1263  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1264  req->ipaddr.struct_size = 24;
1266  ocs_memcpy(req->ipaddr.ip_addr, ipaddr->ip_address, 16);
1267  req->tcp_port = tcp_port;
1268 
1269  return(cmd_off + sizeof(sli4_req_iscsi_tgt_stop_esi_listen_t));
1270 }
1271 
1272 
1273 /**
1274  * @ingroup sli_iscsi
1275  * @brief write a ISCSI_INI_INVALIDATE_CONNECTION command
1276  *
1277  * @param sli4 SLI context
1278  * @param buf destination buffer for the command
1279  * @param size buffer size in bytes
1280  * @param tag command tag
1281  * @param conn_hdl the connection ID
1282  * @param cid the wq_id assigned with the connection
1283  * @param sendRst non-zero sends a TCP reset on the connection.
1284  *
1285  * @return number of bytes written
1286  */
1287 int32_t
1289  size_t size, uint64_t tag,
1290  uint32_t conn_hdl,
1291  uint16_t cid,
1292  uint8_t sendRst)
1293 {
1295  uint32_t cmd_off = 0;
1296  uint32_t payload_size;
1297 
1298  /* Payload length must accomodate both request and response */
1299  payload_size = max(sizeof(sli4_req_iscsi_ini_invalidate_connection_t),
1300  sizeof(sli4_res_hdr_t));
1301 
1302  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1303  NULL);
1304 
1306  ((uint8_t *)buf + cmd_off);
1307 
1310  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1311 
1312  /* not sure if this is necessary b/c 0x8000 flag is used below
1313  * however, open-iscsi be2iscsi driver sets this to the conn_hdl
1314  */
1315  req->session_handle = conn_hdl;
1316  req->cid = cid;
1317 
1318  /* flag 0x8000 indicates that session_handle field is ignored;
1319  * this is used for the Open iSCSI model
1320  */
1321  req->cleanup_type = (sendRst ? 0x8002 : 0x8001);
1322 
1323  return(cmd_off + sizeof(sli4_req_iscsi_ini_invalidate_connection_t));
1324 }
1325 
1326 
1327 /**
1328  * @ingroup sli_iscsi
1329  * @brief write a ISCSI_TGT_ISNS_SEND_PACKET command
1330  *
1331  * @param sli4 SLI context
1332  * @param buf destination buffer for the command
1333  * @param size buffer size in bytes
1334  * @param tag command tag
1335  * @param isns_server the IP address of the iSNS server
1336  * @param tcp_port the TCP port number of the iSNS server
1337  * @param packet the virtual memory pointer to the packet data
1338  * @param pkt_length The number of bytes to transmit.
1339  * @param pkt_mem the DMA buffer that may be used to trasmit the packet
1340  *
1341  * @return number of bytes written
1342  */
1343 int32_t
1345  size_t size, uint64_t tag,
1346  ocs_hal_ip_address_t *isns_server,
1347  uint32_t tcp_port,
1348  void *packet,
1349  uint32_t pkt_length,
1350  ocs_dma_t *pkt_mem)
1351 {
1353  uint32_t cmd_off = 0;
1354  uint32_t payload_size;
1355 
1356  /* Make sure the packet fits in the DMA buffer */
1357  if (pkt_length > pkt_mem->size - sizeof(sli4_req_iscsi_tgt_isns_send_packet_t)) {
1358  ocs_log_test(sli4->os, "iSNS packet of size %d is too big for DMA buffer of size %d\n",
1359  pkt_length,
1360  (uint32_t)(pkt_mem->size - sizeof(sli4_req_iscsi_tgt_isns_send_packet_t)));
1361  return 0;
1362  }
1363 
1364  /* Payload length must accomodate both request and response */
1365  payload_size = max(sizeof(sli4_req_iscsi_tgt_isns_send_packet_t),
1366  pkt_mem->size);
1367 
1368  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag,
1369  payload_size, pkt_mem);
1370 
1371  ocs_memset(pkt_mem->virt, 0, pkt_mem->size);
1372  req = (sli4_req_iscsi_tgt_isns_send_packet_t*)pkt_mem->virt;
1373 
1376  req->hdr.request_length = pkt_mem->size - sizeof(sli4_req_hdr_t);
1377  req->isns_server.struct_size = 24;
1379  ocs_memcpy(req->isns_server.ip_addr, isns_server->ip_address, 16);
1380  req->isns_server.tcp_port = tcp_port;
1381  req->pkt_size = pkt_length;
1382 
1383  /* Copy the iSNS packet bytes to the DMA buffer */
1384  ocs_memcpy(((uint8_t*)req) + sizeof(sli4_req_iscsi_tgt_isns_send_packet_t),
1385  packet,
1386  pkt_length);
1387 
1388  return(cmd_off + sizeof(sli4_req_iscsi_tgt_isns_send_packet_t));
1389 }
1390 
1391 
1392 /**
1393  * @ingroup sli_iscsi
1394  * @brief write a ISCSI_WQ_CREATE command
1395  *
1396  * @param sli4 SLI context
1397  * @param buf destination buffer for the command
1398  * @param size buffer size in bytes
1399  * @param tag command tag
1400  * @param qmem DMA memory for the queue
1401  * @param cq_id associated CQ_ID
1402  * @param ulp The ULP to bind the queue to (if dual ULP aware).
1403  *
1404  * @note This creates a Version 0 message
1405  *
1406  * @return number of bytes written
1407  */
1408 int32_t
1409 sli_cmd_iscsi_wq_create(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1410  ocs_dma_t *qmem, uint16_t cq_id, uint16_t ulp)
1411 {
1412  sli4_req_iscsi_wq_create_t *wq = NULL;
1413  uint32_t cmd_off = 0;
1414  uint32_t p;
1415  uintptr_t addr;
1416  uint32_t payload_size;
1417 
1418  /* Payload length must accomodate both request and response */
1419  payload_size = max(sizeof(sli4_req_iscsi_wq_create_t),
1421 
1422  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1423  NULL);
1424  wq = (sli4_req_iscsi_wq_create_t *)((uint8_t *)buf + cmd_off);
1425 
1429  sizeof(sli4_req_hdr_t);
1430  /* valid values for number of pages: 1-4 (sec 4.5.1) */
1431  wq->num_pages = SLI_PAGE_COUNT(qmem->size);
1432 
1433  if (sli4->features.dual_ulp_capable) {
1434  wq->dua = 1;
1435  wq->bqu = 1;
1436  wq->ulp = ulp;
1437  }
1438 
1440  return 0;
1441  }
1442 
1443  for (p = 0, addr = qmem->phys;
1444  p < wq->num_pages;
1445  p++, addr += SLI_PAGE_SIZE) {
1446  wq->page_physical_address[p].low = ocs_addr32_lo(addr);
1447  wq->page_physical_address[p].high = ocs_addr32_hi(addr);
1448  }
1449 
1450  return(cmd_off + sizeof(sli4_req_iscsi_wq_create_t));
1451 }
1452 
1453 /**
1454  * @ingroup sli_iscsi
1455  * @brief write a ISCSI_WQ_DESTROY command
1456  *
1457  * @param sli4 SLI context
1458  * @param buf destination buffer for the command
1459  * @param size buffer size in bytes
1460  * @param tag command tag
1461  * @param wq_id WQ_ID
1462  *
1463  * @return number of bytes written
1464  */
1465 int32_t
1466 sli_cmd_iscsi_wq_destroy(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1467  uint16_t wq_id)
1468 {
1469  sli4_req_iscsi_wq_destroy_t *wq = NULL;
1470  uint32_t cmd_off = 0;
1471  uint32_t payload_size;
1472 
1473  /* Payload length must accomodate both request and response */
1474  payload_size = max(sizeof(sli4_req_iscsi_wq_destroy_t),
1475  sizeof(sli4_res_hdr_t));
1476 
1477  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1478  NULL);
1479  wq = (sli4_req_iscsi_wq_destroy_t *)((uint8_t *)buf + cmd_off);
1480 
1484  sizeof(sli4_req_hdr_t);
1485  wq->wq_id = wq_id;
1486 
1487  return(cmd_off + sizeof(sli4_req_iscsi_wq_destroy_t));
1488 }
1489 
1490 
1491 /**
1492  * @ingroup sli_iscsi
1493  * @brief write a ISCSI_NTWK_SET_MTU command
1494  *
1495  * @param sli4 SLI context
1496  * @param buf destination buffer for the command
1497  * @param size buffer size in bytes
1498  * @param tag command tag
1499  * @param mtu the MTU size to set (usually 1500 or 8342 bytes)
1500  *
1501  * @return number of bytes written
1502  */
1503 int32_t
1504 sli_cmd_iscsi_ntwk_set_mtu(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1505  uint32_t mtu)
1506 {
1507  sli4_req_iscsi_ntwk_set_mtu_t *req = NULL;
1508  uint32_t cmd_off = 0;
1509  uint32_t payload_size;
1510 
1511  /* Payload length must accomodate both request and response */
1512  payload_size = max(sizeof(sli4_req_iscsi_ntwk_set_mtu_t),
1513  sizeof(sli4_res_hdr_t));
1514 
1515  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1516  NULL);
1517  req = (sli4_req_iscsi_ntwk_set_mtu_t *)((uint8_t *)buf + cmd_off);
1518 
1522  sizeof(sli4_req_hdr_t);
1523  req->mtu = mtu;
1524 
1525  return(cmd_off + sizeof(sli4_req_iscsi_ntwk_set_mtu_t));
1526 }
1527 
1528 
1529 /**
1530  * @ingroup sli_iscsi
1531  * @brief write a ISCSI_TCP_CONNECT_AND_OFFLOAD V0 command
1532  *
1533  * @param sli4 SLI context
1534  * @param buf destination buffer for the command
1535  * @param size buffer size in bytes
1536  * @param tag command tag
1537  * @param ipaddr the IP address
1538  * @param tcp_port the TCP port number
1539  * @param cid The WQ id for this connection
1540  * @param cq_id The completion queue to be used for this conenction.
1541  * @param data_out the DMA buffer that may is used data-out and NOP headers
1542  * @param hdr_ring_id the receive header queue assigned to this connection
1543  * @param data_ring_id the receive data queue assigned to this connection
1544  * @param do_offload non-zero instructs the FW to offload the connection.
1545  *
1546  * @return number of bytes written
1547  */
1548 int32_t
1549 sli_cmd_iscsi_tcp_connect_v0(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1550  ocs_hal_ip_address_t *ipaddr,
1551  uint32_t tcp_port,
1552  uint16_t cid,
1553  uint16_t cq_id,
1554  ocs_dma_t *data_out,
1555  uint16_t hdr_ring_id,
1556  uint16_t data_ring_id,
1557  uint8_t do_offload)
1558 {
1559  sli4_req_iscsi_tcp_connect_v0_t *req = NULL;
1560  uint32_t cmd_off = 0;
1561  uint32_t payload_size;
1562 
1563  /* Payload length must accomodate both request and response */
1564  payload_size = max(sizeof(sli4_req_iscsi_tcp_connect_v0_t),
1566 
1567  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1568  NULL);
1569  req = (sli4_req_iscsi_tcp_connect_v0_t *)((uint8_t *)buf + cmd_off);
1570 
1574  sizeof(sli4_req_hdr_t);
1575  req->ipaddr.struct_size = 24;
1577  ocs_memcpy(req->ipaddr.ip_addr, ipaddr->ip_address, 16);
1578  req->tcp_port = tcp_port;
1579  req->cid = cid;
1580  req->cq_id = cq_id;
1581  req->defq_id = hdr_ring_id;
1582  req->data_out_tmpl_low = ocs_addr32_lo(data_out->phys);
1583  req->data_out_tmpl_high = ocs_addr32_hi(data_out->phys);
1584  req->hdr_ring_id = hdr_ring_id;
1585  req->data_ring_id = data_ring_id;
1586  req->do_offload = (do_offload ? 1 : 0);
1587 
1588  return(cmd_off + sizeof(sli4_req_iscsi_tcp_connect_v0_t));
1589 }
1590 
1591 
1592 int32_t
1594  size_t size, uint64_t tag,
1595  ocs_hal_ip_address_t *ipaddr,
1596  uint32_t tcp_port,
1597  uint16_t cid,
1598  uint16_t cq_id,
1599  ocs_dma_t *data_out,
1600  uint16_t hdr_ring_id,
1601  uint16_t data_ring_id,
1602  uint8_t do_offload,
1603  uint16_t window_size,
1604  uint8_t window_scale,
1605  uint32_t tcp_mss)
1606 {
1607  sli4_req_iscsi_tcp_connect_v1_t *req = NULL;
1608  uint32_t cmd_off = 0;
1609  uint32_t payload_size;
1610 
1611  /* Payload length must accomodate both request and response */
1612  payload_size = max(sizeof(sli4_req_iscsi_tcp_connect_v1_t),
1614 
1615  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1616  NULL);
1617  req = (sli4_req_iscsi_tcp_connect_v1_t *)((uint8_t *)buf + cmd_off);
1618 
1621  req->hdr.version = 1;
1623  sizeof(sli4_req_hdr_t);
1624  req->ipaddr.struct_size = 24;
1626  ocs_memcpy(req->ipaddr.ip_addr, ipaddr->ip_address, 16);
1627  req->tcp_port = tcp_port;
1628  req->cid = cid;
1629  req->cq_id = cq_id;
1630  req->defq_id = hdr_ring_id;
1631  req->data_out_tmpl_low = ocs_addr32_lo(data_out->phys);
1632  req->data_out_tmpl_high = ocs_addr32_hi(data_out->phys);
1633  req->hdr_ring_id = hdr_ring_id;
1634  req->data_ring_id = data_ring_id;
1635  req->do_offload = (do_offload ? 1 : 0);
1636  req->window_size = window_size;
1637  req->window_shift = window_scale;
1638  req->tcp_mss = tcp_mss;
1639 
1640  return(cmd_off + sizeof(sli4_req_iscsi_tcp_connect_v1_t));
1641 }
1642 
1643 
1644 /**
1645  * @ingroup sli_iscsi
1646  * @brief write a ISCSI_TCP_DISCONNECT command
1647  *
1648  * @param sli4 SLI context
1649  * @param buf destination buffer for the command
1650  * @param size buffer size in bytes
1651  * @param tag command tag
1652  * @param conn_hdl the connection handle returned from the
1653  * TCP_CONNECT
1654  *
1655  * @return number of bytes written
1656  */
1657 int32_t
1658 sli_cmd_iscsi_tcp_disconnect(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1659  uint32_t conn_hdl)
1660 {
1661  sli4_req_iscsi_tcp_disconnect_t *req = NULL;
1662  uint32_t cmd_off = 0;
1663  uint32_t payload_size;
1664 
1665  /* Payload length must accomodate both request and response */
1666  payload_size = max(sizeof(sli4_req_iscsi_tcp_disconnect_t),
1667  sizeof(sli4_res_hdr_t));
1668 
1669  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1670  NULL);
1671  req = (sli4_req_iscsi_tcp_disconnect_t *)((uint8_t *)buf + cmd_off);
1672 
1676  sizeof(sli4_req_hdr_t);
1677  req->conn_handle = conn_hdl;
1678 
1679  return(cmd_off + sizeof(sli4_req_iscsi_tcp_disconnect_t));
1680 }
1681 
1682 /**
1683  * @ingroup sli_iscsi
1684  * @brief write a ISCSI_GET_CONNECTION_INFO command
1685  *
1686  * @param sli4 SLI context
1687  * @param buf destination buffer for the command
1688  * @param size buffer size in bytes
1689  * @param tag command tag
1690  * @param conn_hdl the connection handle
1691  *
1692  * @return number of bytes written
1693  */
1694 int32_t
1696  size_t size, uint64_t tag,
1697  uint32_t conn_hdl)
1698 {
1700  uint32_t cmd_off = 0;
1701  uint32_t payload_size;
1702 
1703  /* Payload length must accomodate both request and response */
1704  payload_size = max(sizeof(sli4_req_iscsi_get_connection_info_t),
1706 
1707  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1708  NULL);
1709 
1711  ((uint8_t *)buf + cmd_off);
1712 
1715  req->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
1716  req->conn_handle = conn_hdl;
1717 
1718  return(cmd_off + sizeof(sli4_req_iscsi_get_connection_info_t));
1719 }
1720 
1721 
1722 
1723 /**
1724  * @ingroup sli_iscsi
1725  * @brief write a COMMON_ISCSI_INVALIDATE_COMMANDS command
1726  *
1727  * @param sli4 SLI context
1728  * @param buf destination buffer for the command
1729  * @param size buffer size in bytes
1730  * @param tag command tag
1731  * @param msg_mem pointer to DMA memory required to build the non-embedded command
1732  * @param ios pointer to an array of IOs to abort.
1733  * @param num_ios The number of IOs to abort
1734  * @param abort_type The type of abort to perform
1735  *
1736  * @return number of bytes written
1737  */
1738 int32_t
1739 sli_cmd_iscsi_invalidate_cmds(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1740  ocs_dma_t *msg_mem,
1741  ocs_hal_io_t **ios, uint16_t num_ios,
1742  ocs_hal_abort_type_e abort_type)
1743 {
1745  uint32_t cmd_off = 0;
1746  uint32_t payload_size;
1747  uint32_t index;
1748 
1749  if (num_ios > 128) {
1750  ocs_log_test(sli4->os, "%d ios is too many for command\n", num_ios);
1751  return -1;
1752  }
1753 
1754  /* Payload length must accomodate both request and response */
1755  payload_size = max(sizeof(sli4_req_common_iscsi_invalidate_cmds_t),
1757 
1758  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1759  msg_mem);
1760 
1761  req = (sli4_req_common_iscsi_invalidate_cmds_t *)msg_mem->virt;
1762 
1763  ocs_memset(req, 0, msg_mem->size);
1766  req->hdr.request_length = msg_mem->size - sizeof(sli4_req_hdr_t);
1767 
1768  req->ref_handle = 0;
1769  req->icd_count = num_ios;
1770  req->cleanup_type = (abort_type == OCS_HAL_IO_ABORT_TYPE_TMF ? 1 : 2);
1771  for (index = 0; index < num_ios; index++) {
1772  ocs_cxn_t *cxn = ios[index]->node;
1773 
1774  req->icds[index].icd = ios[index]->icd;
1775  req->icds[index].cid = cxn->wq_id;
1776  }
1777 
1778  return(cmd_off + sizeof(sli4_req_common_iscsi_invalidate_cmds_t));
1779 }
1780 
1781 
1782 /**
1783  * @ingroup sli_iscsi
1784  * @brief write a COMMON_ISCSI_CFG_REMOVE_SGL_PAGES command
1785  *
1786  * @param sli4 SLI context
1787  * @param buf destination buffer for the command
1788  * @param size buffer size in bytes
1789  * @param tag command tag
1790  *
1791  * @return number of bytes written
1792  */
1793 int32_t
1794 sli_cmd_iscsi_remove_sgl_pages(sli4_t *sli4, void *buf, size_t size, uint64_t tag)
1795 {
1797  uint32_t cmd_off = 0;
1798  uint32_t payload_size;
1799 
1800  /* Payload length must accomodate both request and response */
1801  payload_size = max(sizeof(sli4_req_common_iscsi_cfg_remove_sgl_pages_t),
1802  sizeof(sli4_res_hdr_t));
1803 
1804  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1805  NULL);
1806 
1807  cmd = (sli4_req_common_iscsi_cfg_remove_sgl_pages_t *)((uint8_t *)buf + cmd_off);
1808 
1812  sizeof(sli4_req_hdr_t);
1813 
1814  return(cmd_off + sizeof(sli4_req_common_iscsi_cfg_remove_sgl_pages_t));
1815 }
1816 
1817 /**
1818  * @ingroup sli_iscsi
1819  * @brief write a ISCSI_DEFQ_CREATE command
1820  *
1821  * @param sli4 SLI context
1822  * @param buf destination buffer for the command
1823  * @param size buffer size in bytes
1824  * @param tag command tag
1825  * @param qmem DMA memory for the queue
1826  * @param num_entries The number of entries in the queue.
1827  * @param cq_id the completion queue id assigned for this work queue
1828  * @param buffer_size buffer size pointed to by each RQE
1829  * @param ulp The ULP to bind the queue to (if dual ULP aware).
1830  *
1831  * @note This creates a Version 0 message
1832  *
1833  * @return number of bytes written
1834  */
1835 int32_t
1836 sli_cmd_iscsi_defq_create(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1837  ocs_dma_t *qmem, uint32_t num_entries, uint16_t cq_id,
1838  uint16_t buffer_size, uint16_t ulp)
1839 {
1840  sli4_req_iscsi_defq_create_t *defq = NULL;
1841  uint32_t cmd_off = 0;
1842  uint32_t p;
1843  uintptr_t addr;
1844  uint32_t payload_size;
1845 
1846  /* Payload length must accomodate both request and response */
1847  payload_size = max(sizeof(sli4_req_iscsi_defq_create_t),
1849 
1850  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1851  NULL);
1852  defq = (sli4_req_iscsi_defq_create_t *)((uint8_t *)buf + cmd_off);
1853 
1857  sizeof(sli4_req_hdr_t);
1858  /* valid values for number of pages: 1-8 (sec 4.5.6) */
1859  defq->num_pages = SLI_PAGE_COUNT(qmem->size);
1860  if (!defq->num_pages || (defq->num_pages > SLI4_ISCSI_DEFQ_CREATE_V0_MAX_PAGES)) {
1861  ocs_log_test(sli4->os, "num_pages %d not valid\n", defq->num_pages);
1862  return 0;
1863  }
1864 
1865  if (sli4->features.dual_ulp_capable) {
1866  defq->dua = 1;
1867  defq->bqu = 1;
1868  defq->ulp = ulp;
1869  }
1870 
1871  /*
1872  * rind size is the log base 2 of the total number of entries
1873  */
1874  defq->ring_size = ocs_lg2(num_entries) + 1;
1875  defq->cq_id = cq_id;
1876 
1877  if ((buffer_size < SLI4_ISCSI_DEFQ_CREATE_V0_MIN_BUF_SIZE) ||
1878  (buffer_size > SLI4_ISCSI_DEFQ_CREATE_V0_MAX_BUF_SIZE)) {
1879  ocs_log_test(sli4->os, "buffer_size %d out of range (%d-%d)\n",
1880  buffer_size,
1883  return -1;
1884  }
1885  defq->buffer_size = buffer_size;
1886 
1887  for (p = 0, addr = qmem->phys;
1888  p < defq->num_pages;
1889  p++, addr += SLI_PAGE_SIZE) {
1890  defq->page_physical_address[p].low = ocs_addr32_lo(addr);
1891  defq->page_physical_address[p].high = ocs_addr32_hi(addr);
1892  }
1893 
1894  return(cmd_off + sizeof(sli4_req_iscsi_defq_create_t));
1895 }
1896 
1897 /**
1898  * @ingroup sli_iscsi
1899  * @brief write a ISCSI_DEFQ_DESTROY command
1900  *
1901  * @param sli4 SLI context
1902  * @param buf destination buffer for the command
1903  * @param size buffer size in bytes
1904  * @param tag command tag
1905  * @param rq_id RQ_ID
1906  *
1907  * @return number of bytes written
1908  */
1909 int32_t
1910 sli_cmd_iscsi_defq_destroy(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
1911  uint16_t rq_id)
1912 {
1913  sli4_req_iscsi_defq_destroy_t *defq = NULL;
1914  uint32_t cmd_off = 0;
1915  uint32_t payload_size;
1916 
1917  /* Payload length must accomodate both request and response */
1918  payload_size = max(sizeof(sli4_req_iscsi_defq_destroy_t),
1919  sizeof(sli4_res_hdr_t));
1920 
1921  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
1922  NULL);
1923  defq = (sli4_req_iscsi_defq_destroy_t *)((uint8_t *)buf + cmd_off);
1924 
1928  sizeof(sli4_req_hdr_t);
1929  defq->id = rq_id;
1930 
1931  return(cmd_off + sizeof(sli4_req_iscsi_defq_destroy_t));
1932 }
1933 
1934 
1935 /**
1936  * @ingroup sli_iscsi
1937  * @brief Process an asynchronous Link State event entry
1938  *
1939  * Parses ACQE, creates an abstracted event and calls registered callback functions.
1940  *
1941  * @param sli4 SLI context
1942  * @param acqe pointer to Asynchrounous Completion Queue Entry
1943  *
1944  * @return 0 on success, non-zero otherwise
1945  */
1946 int32_t
1948 {
1949  sli4_link_state_t *link_state = acqe;
1950  sli4_link_event_t event = { 0 };
1951  int32_t rc = 0;
1952 
1953  if (!sli4->link) {
1954  // bail if there is no callback
1955  return 0;
1956  }
1957 
1958  /*
1959  * Skyhawk has added a new defineition for bit 1 of this field
1960  * 0 - Physical link
1961  * 1 - Logical link
1962  *
1963  * For our purposes, we don't care, just mask the first bit.
1964  */
1965  switch (link_state->attn_type & 1) {
1967  event.status = SLI_LINK_STATUS_DOWN;
1968  break;
1970  event.status = SLI_LINK_STATUS_UP;
1971  break;
1972  default:
1973  ocs_log_test(sli4->os, "unsupported link status %#x\n",
1974  link_state->attn_type);
1975  event.status = SLI_LINK_STATUS_MAX;
1976  rc = -1;
1977  }
1978 
1979  switch (link_state->port_speed) {
1980  case 0:
1981  event.speed = 0;
1982  break;
1983  case 1:
1984  event.speed = 10;
1985  break;
1986  case 2:
1987  event.speed = 100;
1988  break;
1989  case 3:
1990  event.speed = 1000;
1991  break;
1992  case 4:
1993  event.speed = 10000;
1994  break;
1995  case 5:
1996  event.speed = 20000;
1997  break;
1998  case 6:
1999  event.speed = 25000;
2000  break;
2001  case 7:
2002  event.speed = 40000;
2003  break;
2004  case 8:
2005  event.speed = 100000;
2006  break;
2007  default:
2008  ocs_log_test(sli4->os, "unsupported port_speed %#x\n",
2009  link_state->port_speed);
2010  rc = -1;
2011  }
2012 
2013  sli4->link(sli4->link_arg, (void *)&event);
2014 
2015  return rc;
2016 }
2017 
2018 /**
2019  * @ingroup sli_iscsi
2020  * @brief Process an asynchronous iSCSI event entry
2021  *
2022  * Parses ACQE, creates an abstracted event and calls registered callback functions.
2023  *
2024  * @param sli4 SLI context
2025  * @param acqe pointer to Asynchrounous Completion Queue Entry
2026  *
2027  * @todo XXX all events return LINK_UP
2028  *
2029  * @return 0 on success, non-zero otherwise
2030  */
2031 int32_t
2033 {
2034  sli4_iscsi_t *iscsi_acqe = acqe;
2035  int32_t rc = 0;
2036 
2038  sli4_new_tcp_cnx_event_t *new_tcp = &event.params.new_tcp;
2039  sli4_stateless_op_cmpl_event_t *stateless_cmpl = &event.params.stateless_cmpl;
2040  sli4_dhcp_op_cmpl_event_t *dhcp_cmpl = &event.params.dhcp_cmpl;
2041  sli4_icmpv6_error_event_t *icmp_err = &event.params.icmp_err;
2042  sli4_port_mtu_chg_event_t *mtu_chg = &event.params.mtu_chg;
2043 
2044  sli4_iscsi_new_tcp_cnx_accepted_t *tcp_event = NULL;
2045  sli4_iscsi_stateless_op_cmpl_t *stateless_event = NULL;
2046  sli4_iscsi_dhcp_op_cmpl_t *dhcp_event = NULL;
2047  sli4_iscsi_icmpv6_error_t *icmp_event = NULL;
2048  sli4_iscsi_port_mtu_changed_t *mtu_event = NULL;
2049 
2050  ocs_memset(&event, 0, sizeof(sli4_iscsi_async_event_t));
2051  switch (iscsi_acqe->event_type) {
2053  tcp_event = acqe;
2054  event.event = SLI_ISCSI_ASYNC_NEW_TCP;
2055  new_tcp->cid = tcp_event->cid;
2056  ocs_log_debug(sli4->os, "ACQE New TCP Connection 0x%x\n", tcp_event->cid);
2057  break;
2059  stateless_event = acqe;
2061  stateless_cmpl->status = stateless_event->status;
2062  stateless_cmpl->additional_status = stateless_event->additional_status;
2063  stateless_cmpl->iface = stateless_event->iface;
2064  ocs_log_debug(sli4->os, "Stateless operation complete - IPv4\n");
2065  break;
2067  stateless_event = acqe;
2069  stateless_cmpl->status = stateless_event->status;
2070  stateless_cmpl->additional_status = stateless_event->additional_status;
2071  stateless_cmpl->iface = stateless_event->iface;
2072  ocs_log_debug(sli4->os, "Stateless operation complete - IPv6\n");
2073  break;
2075  dhcp_event = acqe;
2076  event.event = SLI_ISCSI_ASYNC_DHCP_OP_CMPL;
2077  dhcp_cmpl->status = dhcp_event->status;
2078  dhcp_cmpl->additional_status = dhcp_event->additional_status;
2079  dhcp_cmpl->iface = dhcp_event->iface;
2080  ocs_log_debug(sli4->os, "DHCP operation complete\n");
2081  break;
2083  icmp_event = acqe;
2084  event.event = SLI_ISCSI_ASYNC_ICMPV6_ERROR;
2085  icmp_err->iface = icmp_event->iface;
2086  icmp_err->error_code = icmp_event->error_code;
2087  ocs_log_debug(sli4->os, "iSMPv6 Error packet received\n");
2088  break;
2090  mtu_event = acqe;
2091  event.event = SLI_ISCSI_ASYNC_PORT_MTU_CHANGED;
2092  mtu_chg->new_mtu = mtu_event->new_mtu;
2093  ocs_log_debug(sli4->os, "IPv6 default port MTU changed\n");
2094  break;
2095  default:
2096  event.event = SLI_ISCSI_ASYNC_MAX;
2097  ocs_log_test(sli4->os, "unsupported iSCSI ACQE type %#x\n",
2098  iscsi_acqe->event_type);
2099  rc = -1;
2100  }
2101 
2102  if (sli4->iscsi_async) {
2103  sli4->iscsi_async(sli4->iscsi_async_arg, (void *)&event);
2104  }
2105  return rc;
2106 }
2107 
2108 /**
2109  * @ingroup sli_iscsi
2110  * @brief Parse a iSCSI work queue CQ entry
2111  *
2112  * @param sli4 SLI context
2113  * @param cq CQ to process
2114  * @param cqe pointer to the CQ entry
2115  * @param fields returns the fields embedded in the CQ entry
2116  *
2117  * @return 0 on success, non-zero otherwise
2118  */
2119 int32_t
2120 sli_iscsi_cqe_parse(sli4_t *sli4, sli4_queue_t *cq, uint8_t *cqe,
2121  sli4_qentry_fields_t *fields)
2122 {
2123  int32_t rc = -1;
2125  uint32_t code = sol_cqe->code;
2126 
2127  if (code <= ISCSI_CQE_CODE_MAX) {
2128  if (cq->u.flag.is_ini_cq) {
2129  if (sli4->is_skyhawk) {
2130  rc = ini_skh_cqe_handlers[code](sli4,
2131  cqe, fields);
2132  } else {
2133  rc = ini_be3_cqe_handlers[code](sli4,
2134  cqe, fields);
2135  }
2136  } else {
2137  if (sli4->is_skyhawk) {
2138  rc = tgt_skh_cqe_handlers[code](sli4,
2139  cqe, fields);
2140  } else {
2141  rc = tgt_be3_cqe_handlers[code](sli4,
2142  cqe, fields);
2143  }
2144  }
2145  } else {
2146  ocs_log_test(sli4->os, "CQE code 0x%x exceeds max code value of 0x%x - discarded\n",
2147  code, ISCSI_CQE_CODE_MAX);
2148  ocs_dump32(OCS_DEBUG_ALWAYS, sli4->os, "cqe", cqe,
2149  sizeof(sli4_iscsi_common_cqe_t));
2150  }
2151 
2152  return rc;
2153 }
2154 
2155 /**
2156  * @ingroup sli_iscsi
2157  * @brief allocate a receive queue
2158  *
2159  * Allocates DMA memory and configures the requested queue type
2160  *
2161  * @param sli4 SLI context
2162  * @param header pointer to queue object for header
2163  * @param payload pointer to queue object for payload
2164  * @param n_entries number of entries to allocate
2165  * @param hsize header buffer size
2166  * @param psize payload buffer size
2167  * @param cq pointer to the completion queue to use for this queue.
2168  * @param ulp The ULP to bind the queue to (if dual ULP aware).
2169  *
2170  * @return 0 on success, -1 otherwise
2171  */
2172 int32_t
2174  uint32_t n_entries, uint32_t hsize, uint32_t psize,
2175  sli4_queue_t *cq, uint16_t ulp)
2176 {
2177 
2178  if (!sli4 || !header || !payload) {
2179  ocs_log_err(NULL,
2180  "bad parameter sli4=%p header=%p payload=%p\n",
2181  sli4, header, payload);
2182  return -1;
2183  }
2184 
2185  ocs_memset(header, 0, sizeof(sli4_queue_t));
2186 
2187  if (__sli_queue_init(sli4, header, SLI_QTYPE_RQ, 0,
2188  SLI4_ISCSI_DEFQE_SIZE, n_entries, SLI_PAGE_SIZE)) {
2189  return -1;
2190  }
2191 
2192  if (sli_cmd_iscsi_defq_create(sli4, sli4->bmbx.virt, SLI4_BMBX_SIZE, 0,
2193  &header->dma, n_entries, cq->id, hsize, ulp)) {
2194  if (__sli_create_queue(sli4, header)) {
2195  ocs_dma_free(sli4->os, &header->dma);
2196  ocs_memset(&header->dma, 0, sizeof(ocs_dma_t));
2197  return -1;
2198  }
2199  /* header Q_ID must be even */
2200  if (header->id & 1) {
2201  ocs_log_test(sli4->os, "bad header RQ_ID %d\n", header->id);
2202  ocs_dma_free(sli4->os, &header->dma);
2203  ocs_memset(&header->dma, 0, sizeof(ocs_dma_t));
2204  return -1;
2205  }
2206  } else {
2207  return -1;
2208  }
2209  header->u.flag.is_hdr = TRUE;
2210  if (0 == sli4->if_type) {
2211  header->u.flag.rq_batch = TRUE;
2212  }
2213 
2214  ocs_memset(payload, 0, sizeof(sli4_queue_t));
2215  if (__sli_queue_init(sli4, payload, SLI_QTYPE_RQ, 0,
2216  SLI4_ISCSI_DEFQE_SIZE, n_entries, SLI_PAGE_SIZE)) {
2217  return -1;
2218  }
2219 
2220  if (sli_cmd_iscsi_defq_create(sli4, sli4->bmbx.virt, SLI4_BMBX_SIZE, 0,
2221  &payload->dma, n_entries, cq->id, psize, ulp)) {
2222  if (__sli_create_queue(sli4, payload)) {
2223  return -1;
2224  }
2225  /* payload Q_ID must be 1 bigger than the header Q_ID */
2226  if ((header->id + 1) != payload->id) {
2227  ocs_log_test(sli4->os,
2228  "bad payload RQ_ID %d (header RQ_ID %d\n",
2229  payload->id, header->id);
2230  return -1;
2231  }
2232  } else {
2233  return -1;
2234  }
2235  if (0 == sli4->if_type) {
2236  payload->u.flag.rq_batch = TRUE;
2237  }
2238 
2239  return 0;
2240 }
2241 
2242 
2243 /**
2244  * @ingroup sli_iscsi
2245  * @brief Allocate the SGL pages assigned to the ICD table and post them to
2246  * the chip.
2247  *
2248  * @param sli4 SLI context
2249  *
2250  * @return 0 on success, non-zero otherwise
2251  */
2252 int32_t
2254 {
2255  uint32_t num_bits;
2256  sli4_res_hdr_t *hdr;
2257 
2258  switch (sli4->config.num_sges_per_icd) {
2259  case 32:
2260  num_bits = 5;
2261  break;
2262  case 256:
2263  num_bits = 8;
2264  break;
2265  default:
2266  ocs_log_test(sli4->os, "Invalid # of SGEs per ICD %d "
2267  "must be 32 or 256\n", sli4->config.num_sges_per_icd);
2268  return -1;
2269  }
2270 
2272  sli4->bmbx.virt,
2274  0, /* tag */
2275  num_bits)) {
2276  if (sli_bmbx_command(sli4)) {
2277  ocs_log_crit(sli4->os, "bootstrap mailbox write "
2278  "fail SET_FRAGNUM_BITS\n");
2279  return -1;
2280  }
2281  hdr = (sli4_res_hdr_t *)((uint8_t *)sli4->bmbx.virt +
2282  sizeof(sli4_mqe_hdr_t));
2283 
2284  if (hdr->status) {
2285  ocs_log_test(sli4->os, "bad status SET_FRAGNUM_BITS"
2286  " status=%#x addl=%#x\n", hdr->status,
2287  hdr->additional_status);
2288  return -1;
2289  } else {
2290  ocs_log_debug(sli4->os, "Set for %d SGEs\n", sli4->config.num_sges_per_icd);
2291  }
2292  } else {
2293  ocs_log_test(sli4->os, "Error building SET_FRAGNUM_BITS message\n");
2294  return -1;
2295  }
2296 
2297  return 0;
2298 }
2299 
2300 /**
2301  * @brief write a COMMON_ISCSI_CFG_POST_SGL_PAGES (v0) command
2302  *
2303  * @param sli4 SLI context
2304  * @param buf destination buffer for the command
2305  * @param size buffer size in bytes
2306  * @param tag command tag
2307  * @param pages pointer to an array of DMA page memory
2308  * @param num_pages The number of pages passed
2309  * @param page_offset The index of the page into the ICD SGL pages
2310  *
2311  * @return number of bytes written
2312  */
2313 static int32_t
2314 sli_cmd_iscsi_post_sgl_pages_v0(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
2315  ocs_dma_t *pages, uint16_t num_pages, uint16_t page_offset)
2316 {
2318  uint32_t cmd_off = 0;
2319  uint32_t payload_size;
2320  uint32_t index;
2321 
2322  /* Payload length must accomodate both request and response */
2323  payload_size = max(sizeof(sli4_req_common_iscsi_cfg_post_sgl_pages_v0_t),
2324  sizeof(sli4_res_hdr_t));
2325 
2326  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
2327  NULL);
2328 
2329  post = (sli4_req_common_iscsi_cfg_post_sgl_pages_v0_t *)((uint8_t *)buf + cmd_off);
2330 
2334  sizeof(sli4_req_hdr_t);
2335 
2336  post->numPages = num_pages;
2337  post->page_offset = page_offset;
2338 
2339  for (index = 0; index < num_pages; index++) {
2340  post->page_physical_address[index].low = ocs_addr32_lo(pages[index].phys);
2341  post->page_physical_address[index].high = ocs_addr32_hi(pages[index].phys);
2342  }
2343 
2344  return(cmd_off + sizeof(sli4_req_common_iscsi_cfg_post_sgl_pages_v0_t));
2345 }
2346 
2347 
2348 /**
2349  * @ingroup sli_iscsi
2350  * @brief Allocate the SGL pages assigned to the ICD table and post them to
2351  * the chip.
2352  *
2353  * @param sli4 SLI context
2354  *
2355  * @return 0 on success, non-zero otherwise
2356  */
2357 static int32_t
2359 {
2360  uint32_t indx;
2361  uint32_t page_off = 0;
2362  uint32_t num_to_post;
2363  sli4_res_hdr_t *hdr;
2364 
2365  page_off = sli4->icd_base / sli4->icd_num_per_page;
2366  ocs_log_debug(sli4->os, "ICD SGE page offset is 0x%x, num pages = %d\n",
2367  page_off, sli4->num_sgl_pages);
2368 
2369  indx = 0;
2370  while (indx < sli4->num_sgl_pages) {
2371 
2372  num_to_post = sli4->num_sgl_pages - indx;
2373  if (num_to_post > 26) {
2374  num_to_post = 26;
2375  }
2376 
2378  sli4->bmbx.virt,
2380  0, /* tag */
2381  &sli4->sgl_pages[indx],
2382  (uint16_t)num_to_post,
2383  (uint16_t)page_off)) {
2384  if (sli_bmbx_command(sli4)) {
2385  ocs_log_crit(sli4->os, "bootstrap mailbox write "
2386  "fail CFG_POST_SGL (v0)\n");
2387  return -1;
2388  }
2389  hdr = (sli4_res_hdr_t *)((uint8_t *)sli4->bmbx.virt +
2390  sizeof(sli4_mqe_hdr_t));
2391 
2392  if (hdr->status) {
2393  ocs_log_test(sli4->os, "bad create CFG_POST_SGL (v0)"
2394  " status=%#x addl=%#x\n", hdr->status,
2395  hdr->additional_status);
2396  return -1;
2397  }
2398  } else {
2399  ocs_log_test(sli4->os, "Error building post SGL page (v0) message\n");
2400  return -1;
2401  }
2402 
2403  indx += num_to_post;
2404  page_off += num_to_post;
2405  }
2406 
2407  return 0;
2408 }
2409 
2410 /**
2411  * @brief write a COMMON_ISCSI_CFG_POST_SGL_PAGES (v1) command
2412  *
2413  * @param sli4 SLI context
2414  * @param buf destination buffer for the command
2415  * @param size buffer size in bytes
2416  * @param tag command tag
2417  * @param pages pointer to an array of DMA page memory
2418  * @param icd_start The starting ICD index
2419  * @param icd_count The number of ICD to post (1 page per ICD)
2420  *
2421  * @return number of bytes written
2422  */
2423 static int32_t
2424 sli_cmd_iscsi_post_sgl_pages_v1(sli4_t *sli4, void *buf, size_t size, uint64_t tag,
2425  ocs_dma_t *pages, uint16_t icd_start, uint16_t icd_count)
2426 {
2428  uint32_t cmd_off = 0;
2429  uint32_t payload_size;
2430  uint32_t index;
2431 
2432  /* Payload length must accomodate both request and response */
2433  payload_size = (sizeof(sli4_req_hdr_t) + 4 + /* ICD count and start */
2434  (icd_count * 8)); /* page addresses */
2435 
2436  cmd_off = sli_cmd_mailbox_queue_entry(sli4, buf, size, tag, payload_size,
2437  NULL);
2438 
2439  post = (sli4_req_common_iscsi_cfg_post_sgl_pages_v1_t *)((uint8_t *)buf + cmd_off);
2440 
2443  post->hdr.version = 1;
2444  post->hdr.request_length = payload_size - sizeof(sli4_req_hdr_t);
2445 
2446  post->icd_start = icd_start;
2447  post->icd_count = icd_count;
2448 
2449  for (index = 0; index < icd_count; index++) {
2450  post->page_set[index].page0_low = ocs_addr32_lo(pages[index].phys);
2451  post->page_set[index].page0_high = ocs_addr32_hi(pages[index].phys);
2452  }
2453 
2454  return(cmd_off + sizeof(sli4_req_common_iscsi_cfg_post_sgl_pages_v1_t));
2455 }
2456 
2457 
2458 /**
2459  * @ingroup sli_iscsi
2460  * @brief Allocate the SGL pages assigned to the ICD table and post them to
2461  * the chip.
2462  *
2463  * @param sli4 SLI context
2464  *
2465  * @return 0 on success, non-zero otherwise
2466  */
2467 static int32_t
2469 {
2470  uint32_t page_size = sizeof(sli4_sge_t) * sli4->config.num_sges_per_icd;
2471  uint32_t icd_indx = 0;
2472  uint32_t num_to_post;
2473  sli4_res_hdr_t *hdr;
2474  ocs_dma_t pages[20];
2475  uint32_t page_indx;
2476 
2477  while (icd_indx < sli4->icd_count) {
2478 
2479  num_to_post = sli4->icd_count - icd_indx;
2480  if (num_to_post > 20) {
2481  num_to_post = 20;
2482  }
2483 
2484  /*
2485  * We need to build an array of DMA of "pages", one per ICD,
2486  * but in reality, they are not full pages. FW will never know
2487  * since we will never use that many entries. Chunk the
2488  * allocated pages into each individual ICD.
2489  */
2490  for (page_indx = 0; page_indx < num_to_post; page_indx++) {
2491  uint32_t icd_off = (icd_indx + page_indx);
2492  uint32_t page_num = icd_off / sli4->icd_num_per_page;
2493  uint32_t page_off = ((icd_off % sli4->icd_num_per_page)
2494  * page_size);
2495 
2496  pages[page_indx].virt = (uint8_t*)sli4->sgl_pages[page_num].virt + page_off;
2497  pages[page_indx].phys = sli4->sgl_pages[page_num].phys + page_off;
2498  pages[page_indx].size = page_size;
2499  }
2500 
2502  sli4->bmbx.virt,
2504  0, /* tag */
2505  pages,
2506  (uint16_t)(sli4->icd_base + icd_indx),
2507  (uint16_t)num_to_post)) {
2508  if (sli_bmbx_command(sli4)) {
2509  ocs_log_crit(sli4->os, "bootstrap mailbox write "
2510  "fail CFG_POST_SGL (v1)\n");
2511  return -1;
2512  }
2513  hdr = (sli4_res_hdr_t *)((uint8_t *)sli4->bmbx.virt +
2514  sizeof(sli4_mqe_hdr_t));
2515 
2516  if (hdr->status) {
2517  ocs_log_test(sli4->os, "bad create CFG_POST_SGL (v1)"
2518  " status=%#x addl=%#x\n", hdr->status,
2519  hdr->additional_status);
2520  return -1;
2521  }
2522  } else {
2523  ocs_log_test(sli4->os,
2524  "Error building post SGL page (v1) message\n");
2525  return -1;
2526  }
2527 
2528  icd_indx += num_to_post;
2529  }
2530 
2531  return 0;
2532 }
2533 
2534 
2535 /**
2536  * @ingroup sli_iscsi
2537  * @brief Allocate the SGL pages assigned to the ICD table and post them to
2538  * the chip.
2539  *
2540  * @param sli4 SLI context
2541  *
2542  * @return 0 on success, non-zero otherwise
2543  */
2544 int32_t
2546 {
2547  uint32_t indx;
2548  int32_t rc;
2549 
2550 
2551  /*
2552  * Note: SGEs are 4 dwords, standard number of SGEs is 32 per ICD.
2553  */
2554  sli4->icd_num_per_page = 4096 / (sizeof(sli4_sge_t) * sli4->config.num_sges_per_icd);
2555 
2556  sli4->num_sgl_pages = ((sli4->icd_count + sli4->icd_num_per_page - 1) /
2557  sli4->icd_num_per_page);
2558 
2559  /* Allocate pages */
2560  sli4->sgl_pages = ocs_malloc(sli4->os, sizeof(ocs_dma_t) * sli4->num_sgl_pages,
2561  OCS_M_ZERO | OCS_M_NOWAIT);
2562  if (NULL == sli4->sgl_pages) {
2563  ocs_log_err(sli4->os, "Failed to allocate SGL DMA structures\n");
2564  return -1;
2565  }
2566 
2567  for (indx = 0; indx < sli4->num_sgl_pages; indx++) {
2568  if (ocs_dma_alloc(sli4->os,
2569  &sli4->sgl_pages[indx],
2570  4096,
2571  32)) {
2572  ocs_log_err(sli4->os, "Failed to allocate SGL page %d\n", indx);
2573  return -1;
2574  }
2575  }
2576 
2577  ocs_log_debug(sli4->os, "Use ver %d to register %d SGEs per ICD\n",
2579 
2580  switch (sli4->config.post_sgl_ver) {
2581  case 0:
2582  rc = sli_iscsi_post_sgl_pages_v0(sli4);
2583  break;
2584  case 1:
2585  rc = sli_iscsi_post_sgl_pages_v1(sli4);
2586  break;
2587  default:
2588  ocs_log_test(sli4->os, "Invalid post sgl version of %d\n",
2589  sli4->config.post_sgl_ver);
2590  rc = -1;
2591  }
2592 
2593  return rc;
2594 }
2595 
2596 /**
2597  * @ingroup sli_iscsi
2598  * @brief return the ICD and virtual SGL pointer for an IO at the specified
2599  * offset into the ICD table.
2600  *
2601  * @param sli4 SLI context
2602  * @param io_offset The offset into the ICD table
2603  * @param icd returns the ICD representing this IO.
2604  * @param sgl returns the virtual pointer to the first SGL for this ICD.
2605  *
2606  * @return 0 on success, non-zero otherwise
2607  */
2608 int32_t
2609 sli_iscsi_io_get_icd_and_sgl(sli4_t *sli4, uint32_t io_offset,
2610  uint16_t *icd, void **sgl)
2611 {
2612  int32_t rc = 0;
2613  uint32_t icd_page_off;
2614  uint32_t icd_off;
2615 
2616  if (io_offset >= sli4->icd_count) {
2617  rc = -1;
2618  } else {
2619  *icd = sli4->icd_base + io_offset;
2620 
2621  icd_page_off = io_offset / sli4->icd_num_per_page;
2622  icd_off = ((io_offset % sli4->icd_num_per_page) *
2623  (sizeof(sli4_sge_t) * sli4->config.num_sges_per_icd));
2624 
2625  *sgl = ((uint8_t*)sli4->sgl_pages[icd_page_off].virt) + icd_off;
2626  }
2627  return rc;
2628 }
2629 
2630 /* vim: set noexpandtab textwidth=120: */
This structure contains the type and associated fields for a CQE completion.
Definition: sli4.h:2017
uint8_t is_skyhawk
Definition: sli4.h:2208
uint32_t uint32_t uint32_t tcp_mss
Definition: sli4_iscsi.h:696
int32_t(* link)(void *, void *)
Definition: sli4.h:2255
uint32_t numPages
Definition: sli4_iscsi.h:237
ocs_os_handle_t os
Definition: sli4.h:2202
ISCSI_WQ_CREATE.
Definition: sli4_iscsi.h:613
#define ISCSI_CQE_CODE_MAX
Definition: sli4_iscsi.h:1119
ISCSI_DEFQ_DESTROY.
Definition: sli4_iscsi.h:804
ISCSI_TGT_OFFLOAD_CONNECTION.
Definition: sli4_iscsi.h:927
ocs_hal_ip_type_e ip_type
Definition: ocs_hal.h:268
#define SLI4_OPC_ISCSI_TGT_INVALIDATE_CONNECTION
Definition: sli4_iscsi.h:845
int32_t sli_iscsi_set_frag_bits(sli4_t *sli4)
Allocate the SGL pages assigned to the ICD table and post them to the chip.
Definition: sli4_iscsi.c:2253
#define SLI4_OPC_ISCSI_NTWK_IFACE_DELETE
Definition: sli4_iscsi.h:171
Generic Common Create EQ/CQ/MQ/WQ/RQ Queue completion.
Definition: sli4.h:914
sli4_session_login_options_t session_options
Definition: sli4_iscsi.h:146
uint8_t ip_addr[16]
Definition: sli4_iscsi.h:77
uint32_t additional_status
Definition: sli4.h:606
ISCSI_INI_INVALIDATE_CONNECTION.
Definition: sli4_iscsi.h:822
COMMON_ISCSI_NTWK_IFACE_CREATE.
Definition: sli4_iscsi.h:290
COMMON_ISCSI_CFG_REMOVE_SGL_PAGES.
Definition: sli4_iscsi.h:276
uint32_t num_sgl_pages
Definition: sli4.h:2267
int32_t sli_cmd_iscsi_tgt_invalidate_connection(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl, uint16_t cid, uint8_t sendRst)
write a ISCSI_TGT_INVALIDATE_CONNECTION command
Definition: sli4_iscsi.c:1152
#define SLI4_OPC_ISCSI_NTWK_DISCOVER_ISNS_SERVER
Definition: sli4_iscsi.h:174
#define SLI4_OPC_ISCSI_ERROR_RECOVERY_INVALIDATE_CMDS
Definition: sli4_iscsi.h:165
int32_t sli_cmd_iscsi_common_get_default_gateway(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint8_t isv4)
write a COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY command
Definition: sli4_iscsi.c:509
int32_t sli_cmd_mailbox_queue_entry(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t length, ocs_dma_t *dma)
Write a MQE header in the provided buffer.
Definition: sli4.c:508
cqe_handler_t * ini_be3_cqe_handlers[ISCSI_CQE_CODE_MAX+1]
int32_t sli_cmd_iscsi_common_modify_default_gateway(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint8_t isadd, ocs_hal_ip_address_t *gateway)
write a COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY command
Definition: sli4_iscsi.c:549
#define SLI4_ISCSI_DEFQ_CREATE_V0_MAX_PAGES
Definition: sli4_iscsi.h:794
ISCSI_TGT_ISNS_SEND_PACKET.
Definition: sli4_iscsi.h:973
#define SLI4_ISCSI_WQ_CREATE_V0_MAX_PAGES
Definition: sli4_iscsi.h:630
mailbox queue Element header
Definition: sli4.h:564
int32_t sli_cmd_iscsi_tcp_disconnect(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl)
write a ISCSI_TCP_DISCONNECT command
Definition: sli4_iscsi.c:1658
#define SLI4_ISCSI_ACQE_NEW_TCP_CONNECTION
Definition: sli4_iscsi.h:1121
#define SLI4_OPC_ISCSI_SET_FRAGNUM_BITS
Definition: sli4_iscsi.h:182
#define SLI4_OPC_ISCSI_WQ_DESTROY
Definition: sli4_iscsi.h:186
#define SLI_PAGE_COUNT(b)
Definition: sli4.h:47
uint32_t uint32_t max_rcv_dsl
Definition: sli4_iscsi.h:148
int32_t sli_cmd_iscsi_cleanup_v0(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint16_t ulp_no, uint8_t hdrq_id, uint8_t dataq_id)
write a COMMON_ISCSI_CLEANUP (version 0) command
Definition: sli4_iscsi.c:671
uint8_t subnet[16]
Definition: sli4_iscsi.h:97
uint8_t ip_address[16]
Definition: ocs_hal.h:261
#define SLI4_ISCSI_DEFQ_CREATE_V0_MIN_BUF_SIZE
Definition: sli4_iscsi.h:795
#define SLI4_ISCSI_ACQE_ICMPV6_ERROR_PKT_RECVD
Definition: sli4_iscsi.h:1125
sli4_req_hdr_t hdr
Definition: sli4_iscsi.h:235
int32_t sli_cmd_iscsi_common_get_if_info(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface, uint8_t isv4)
write a COMMON_ISCSI_NTWK_GET_IF_INFO command
Definition: sli4_iscsi.c:629
uint32_t uint32_t hdr_ring_id
Definition: sli4_iscsi.h:583
COMMON_ISCSI_CFG_POST_SGL_PAGES (v1)
Definition: sli4_iscsi.h:256
uint32_t page0_high
Definition: sli4_iscsi.h:263
uint8_t ip_addr[16]
Definition: sli4_iscsi.h:65
uint8_t dual_ulp_capable
Definition: sli4.h:2234
ISCSI_TCP_DISCONNECT.
Definition: sli4_iscsi.h:725
COMMON_ISCSI_NTWK_IFACE_DELETE.
Definition: sli4_iscsi.h:313
cqe_handler_t * ini_skh_cqe_handlers[ISCSI_CQE_CODE_MAX+1]
#define SLI4_OPC_ISCSI_CFG_POST_SGL_PAGES
Definition: sli4_iscsi.h:166
int32_t sli_cmd_iscsi_common_discovered_isns_servers(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface)
write a COMMON_ISCSI_NTWK_DISCOVERED_ISNS_SERVERS command
Definition: sli4_iscsi.c:269
uint8_t tcp_offload_nrs
Definition: sli4.h:2229
#define SLI4_OPC_ISCSI_TGT_START_LISTEN_SERVER
Definition: sli4_iscsi.h:839
int32_t sli_cmd_iscsi_tgt_offload_connection_v1(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl, uint32_t tcp_window_size, uint16_t ulp_no, uint16_t wq_id, uint16_t cq_id, uint16_t hdrq_id, uint16_t dataq_id, uint8_t nrs, ocs_hal_target_login_options_t *lgn_options)
write a ISCSI_TGT_OFFLOAD_CONNECTION command (version 1)
Definition: sli4_iscsi.c:1069
#define SLI4_OPC_ISCSI_NTWK_GET_DEFAULT_GATEWAY
Definition: sli4_iscsi.h:177
structure wrapping an IP address and subnet together with their type.
Definition: ocs_hal.h:267
#define SLI_PAGE_SIZE
Definition: sli4.h:43
struct sli4_queue_t::@33::@34 flag
uint32_t event_type
Definition: sli4_iscsi.h:1134
#define SLI4_OPC_ISCSI_INI_INVALIDATE_CONNECTION
Definition: sli4_iscsi.h:816
ocs_hal_ip_type_e
enum identifying the types of IP addresses.
Definition: ocs_hal.h:244
#define SLI4_ISCSI_DEFQE_SIZE
Definition: sli4_iscsi.h:797
ISCSI_DEFQ_CREATE.
Definition: sli4_iscsi.h:769
ISCSI_WQ_DESTROY.
Definition: sli4_iscsi.h:637
COMMON_ISCSI_SET_FRAGNUM_BITS.
Definition: sli4_iscsi.h:599
#define SLI4_OPC_ISCSI_NTWK_MODIFY_IP_ADDR
Definition: sli4_iscsi.h:176
cqe_handler_t * tgt_be3_cqe_handlers[ISCSI_CQE_CODE_MAX+1]
int32_t sli_iscsi_io_get_icd_and_sgl(sli4_t *sli4, uint32_t io_offset, uint16_t *icd, void **sgl)
return the ICD and virtual SGL pointer for an IO at the specified offset into the ICD table...
Definition: sli4_iscsi.c:2609
Asynchronouse Event : iSCSI Event - iCMPv6 Error.
Definition: sli4_iscsi.h:1228
ocs_hal_abort_type_e
HAL abort types.
Definition: ocs_hal.h:675
COMMON_ISCSI_NTWK_RELEASE_STATELESS_IP_ADDR.
Definition: sli4_iscsi.h:348
#define SLI_LOGIN_FLAG_INITIAL_R2T
Definition: sli4_iscsi.h:135
cqe_handler_t * tgt_skh_cqe_handlers[ISCSI_CQE_CODE_MAX+1]
COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_CMDS.
Definition: sli4_iscsi.h:197
int32_t __sli_queue_init(sli4_t *sli4, sli4_queue_t *q, uint32_t qtype, uint32_t version, size_t size, uint32_t n_entries, uint32_t align)
Initialize a queue object.
Definition: sli4.c:2953
COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY.
Definition: sli4_iscsi.h:491
struct sli4_t::@37 features
uint16_t icd
Definition: ocs_hal.h:474
#define SLI4_OPC_ISCSI_NTWK_SET_ROUTE_TABLE
Definition: sli4_iscsi.h:169
int32_t sli_iscsi_process_iscsi(sli4_t *sli4, void *acqe)
Process an asynchronous iSCSI event entry.
Definition: sli4_iscsi.c:2032
uint32_t uint32_t window_size
Definition: sli4_iscsi.h:696
static int32_t sli_cmd_iscsi_post_sgl_pages_v0(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_dma_t *pages, uint16_t num_pages, uint16_t page_offset)
write a COMMON_ISCSI_CFG_POST_SGL_PAGES (v0) command
Definition: sli4_iscsi.c:2314
uint32_t page_offset
Definition: sli4_iscsi.h:237
struct sli4_req_iscsi_defq_create_t::@44 page_physical_address[8]
int32_t sli_cmd_iscsi_common_discover_isns_server(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface, uint32_t retries)
write a COMMON_ISCSI_NTWK_DISCOVER_ISNS_SERVER command
Definition: sli4_iscsi.c:228
int32_t sli_cmd_iscsi_tcp_connect_v0(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *ipaddr, uint32_t tcp_port, uint16_t cid, uint16_t cq_id, ocs_dma_t *data_out, uint16_t hdr_ring_id, uint16_t data_ring_id, uint8_t do_offload)
write a ISCSI_TCP_CONNECT_AND_OFFLOAD V0 command
Definition: sli4_iscsi.c:1549
COMMON_ISCSI_CLEANUP.
Definition: sli4_iscsi.h:569
#define SLI4_SUBSYSTEM_COMMON_ISCSI
Definition: sli4.h:508
uint32_t icd_count
Definition: sli4.h:2215
int32_t sli_cmd_iscsi_tgt_stop_listen_server(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *ipaddr, uint32_t tcp_port)
write a ISCSI_TGT_STOP_LISTEN_SERVER command
Definition: sli4_iscsi.c:845
uint32_t icd_count
Definition: sli4_iscsi.h:259
uint8_t sli_iscsi_conv_hal_ip_addr_type(ocs_hal_ip_type_e ip_type)
Converts the IP address type field to the SLI4 equivalent value.
Definition: sli4_iscsi.c:305
int32_t sli_cmd_iscsi_common_iface_delete(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface)
write a COMMON_ISCSI_NTWK_IFACE_CREATE command
Definition: sli4_iscsi.c:103
#define OCS_DEBUG_ALWAYS
Definition: ocs_debug.h:154
#define SLI4_ISCSI_ACQE_IPV6_DEFAULT_PORT_MTU_CHANGED
Definition: sli4_iscsi.h:1126
IP_ADDRESS_FORMAT.
Definition: sli4_iscsi.h:60
ocs_dma_t * sgl_pages
Definition: sli4.h:2268
#define SLI4_ISCSI_ACQE_DHCP_OPERATION_COMPLETE
Definition: sli4_iscsi.h:1124
uint32_t uint32_t window_shift
Definition: sli4_iscsi.h:696
union sli4_queue_t::@33 u
int32_t sli_cmd_iscsi_wq_create(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_dma_t *qmem, uint16_t cq_id, uint16_t ulp)
write a ISCSI_WQ_CREATE command
Definition: sli4_iscsi.c:1409
uint32_t status
Definition: sli4.h:606
int32_t sli_cmd_iscsi_tgt_get_connection_info(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl)
write a ISCSI_TGT_GET_CONNECTION_INFO command
Definition: sli4_iscsi.c:889
Asynchronouse Event : iSCSI Event - iCMPv6 Error.
Definition: sli4_iscsi.h:1208
COMMON_ISCSI_NTWK_SET_ROUTE_TABLE.
Definition: sli4_iscsi.h:421
#define SLI4_SUBSYSTEM_ISCSI_TGT
Definition: sli4.h:510
int32_t sli_cmd_iscsi_remove_sgl_pages(sli4_t *sli4, void *buf, size_t size, uint64_t tag)
write a COMMON_ISCSI_CFG_REMOVE_SGL_PAGES command
Definition: sli4_iscsi.c:1794
sli4_req_hdr_t hdr
Definition: sli4_iscsi.h:257
uint32_t opcode
Definition: sli4.h:584
ISCSI_TGT_START_ESI_LISTEN.
Definition: sli4_iscsi.h:1004
#define SLI4_OPC_ISCSI_NTWK_RELEASE_STATELESS_IP_ADDR
Definition: sli4_iscsi.h:173
Definition: sli4.h:2201
int32_t sli_cmd_iscsi_get_connection_info(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl)
write a ISCSI_GET_CONNECTION_INFO command
Definition: sli4_iscsi.c:1695
int32_t sli_cmd_iscsi_tgt_start_esi_listen(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *ipaddr, uint32_t tcp_port)
write a ISCSI_TGT_START_ESI_LISTEN command
Definition: sli4_iscsi.c:1197
#define SLI4_BMBX_SIZE
Definition: sli4.h:128
int32_t sli_iscsi_process_link_state(sli4_t *sli4, void *acqe)
Process an asynchronous Link State event entry.
Definition: sli4_iscsi.c:1947
#define SLI4_SUBSYSTEM_ISCSI_INI
Definition: sli4.h:509
void ocs_dump32(uint32_t mask, ocs_os_handle_t os, const char *label, void *buf, uint32_t buf_length)
Dump 32 bit hex/ascii data.
Definition: ocs_dump32.c:72
int32_t sli_cmd_iscsi_defq_destroy(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint16_t rq_id)
write a ISCSI_DEFQ_DESTROY command
Definition: sli4_iscsi.c:1910
#define SLI4_OPC_ISCSI_NTWK_IFACE_CREATE
Definition: sli4_iscsi.h:170
uint8_t post_sgl_ver
Definition: sli4.h:2242
int32_t(* iscsi_async)(void *, void *)
Definition: sli4.h:2258
uint32_t uint32_t uint32_t ulp_number
Definition: sli4_iscsi.h:952
void * link_arg
Definition: sli4.h:2256
COMMON_ISCSI_CFG_POST_SGL_PAGES (v0)
Definition: sli4_iscsi.h:234
struct sli4_req_common_iscsi_cfg_post_sgl_pages_v0_t::@41 page_physical_address[26]
int32_t sli_cmd_iscsi_common_configure_stateless_ip_addr(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface, uint8_t isv4, uint32_t retries)
write a COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR command
Definition: sli4_iscsi.c:142
#define SLI4_OPC_ISCSI_WQ_CREATE
Definition: sli4_iscsi.h:185
#define SLI4_OPC_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY
Definition: sli4_iscsi.h:178
#define SLI4_PORT_LINK_STATUS_UP
Definition: sli4_iscsi.h:1269
int32_t sli_cmd_iscsi_ntwk_set_mtu(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t mtu)
write a ISCSI_NTWK_SET_MTU command
Definition: sli4_iscsi.c:1504
int32_t sli_cmd_iscsi_wq_destroy(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint16_t wq_id)
write a ISCSI_WQ_DESTROY command
Definition: sli4_iscsi.c:1466
sli4_route_table_entry_t entry[1]
Definition: sli4_iscsi.h:426
#define SLI_LOGIN_FLAG_DATA_PDU_IN_ORDER
Definition: sli4_iscsi.h:137
int32_t sli_cmd_iscsi_invalidate_cmds(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_dma_t *msg_mem, ocs_hal_io_t **ios, uint16_t num_ios, ocs_hal_abort_type_e abort_type)
write a COMMON_ISCSI_INVALIDATE_COMMANDS command
Definition: sli4_iscsi.c:1739
const char * SLI_QNAME[]
Definition: sli4.c:75
ocs_hal_ip_type_e ip_type
Definition: ocs_hal.h:260
COMMON_ISCSI_NTWK_DISCOVERED_ISNS_SERVERS.
Definition: sli4_iscsi.h:379
int32_t sli_cmd_iscsi_common_modify_ip_addr(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface, uint8_t isadd, ocs_hal_ip_address_subnet_t *ipaddr)
write a COMMON_ISCSI_NTWK_MODIFY_IP_ADDR command
Definition: sli4_iscsi.c:462
#define SLI_LOGIN_FLAG_DATA_SEQUENCE_IN_ORDER
Definition: sli4_iscsi.h:138
#define SLI4_OPC_ISCSI_NTWK_DISCOVERED_ISNS_SERVERS
Definition: sli4_iscsi.h:175
HAL IO object.
Definition: ocs_hal.h:471
sli4_ip_addr_subnet_t ip_sub
Definition: sli4_iscsi.h:110
uint32_t version
Definition: sli4.h:590
uint32_t if_type
Definition: sli4.h:2206
uint16_t id
Definition: sli4.h:2054
uint32_t page0_low
Definition: sli4_iscsi.h:262
COMMON_ISCSI_NTWK_DISCOVER_ISNS_SERVER.
Definition: sli4_iscsi.h:363
int32_t sli_iscsi_post_sgl_pages(sli4_t *sli4)
Allocate the SGL pages assigned to the ICD table and post them to the chip.
Definition: sli4_iscsi.c:2545
#define SLI4_OPC_ISCSI_TGT_START_ESI_LISTEN
Definition: sli4_iscsi.h:846
#define SLI4_ISCSI_ACQE_STATELESS_OPERATION_COMPLETE_IPV4
Definition: sli4_iscsi.h:1122
SESSION_LOGIN_OPTIONS.
Definition: sli4_iscsi.h:119
int32_t sli_cmd_iscsi_common_set_route_table(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint8_t isadd, ocs_hal_ip_address_subnet_t *hal_ipsub, ocs_hal_ip_address_t *hal_gateway, ocs_dma_t *dma)
write a COMMON_ISCSI_NTWK_SET_ROUTE_TABLE command
Definition: sli4_iscsi.c:385
ocs_cxn_t * node
Definition: ocs_hal.h:475
int32_t sli_cmd_iscsi_tcp_connect_v1(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *ipaddr, uint32_t tcp_port, uint16_t cid, uint16_t cq_id, ocs_dma_t *data_out, uint16_t hdr_ring_id, uint16_t data_ring_id, uint8_t do_offload, uint16_t window_size, uint8_t window_scale, uint32_t tcp_mss)
Definition: sli4_iscsi.c:1593
#define SLI4_ISCSI_ROUTE_TABLE_ENTRY_ADD
Definition: sli4_iscsi.h:413
#define SLI4_OPC_ISCSI_TCP_CONNECT_AND_OFFLOAD
Definition: sli4_iscsi.h:188
#define SLI_LOGIN_FLAG_IMMEDIATE_DATA
Definition: sli4_iscsi.h:136
uint32_t subsystem
Definition: sli4.h:584
#define SLI4_OPC_ISCSI_TGT_GET_CONNECTION_INFO
Definition: sli4_iscsi.h:841
int32_t sli_cmd_iscsi_tgt_isns_send_packet(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *isns_server, uint32_t tcp_port, void *packet, uint32_t pkt_length, ocs_dma_t *pkt_mem)
write a ISCSI_TGT_ISNS_SEND_PACKET command
Definition: sli4_iscsi.c:1344
Asynchronouse Event : iSCSI Event - New TCP Connection.
Definition: sli4_iscsi.h:1148
int32_t sli_iscsi_defq_alloc(sli4_t *sli4, sli4_queue_t *header, sli4_queue_t *payload, uint32_t n_entries, uint32_t hsize, uint32_t psize, sli4_queue_t *cq, uint16_t ulp)
allocate a receive queue
Definition: sli4_iscsi.c:2173
struct sli4_t::@38 config
COMMON_ISCSI_NTWK_MODIFY_IP_ADDR.
Definition: sli4_iscsi.h:399
uint32_t uint32_t uint32_t data_ring_id
Definition: sli4_iscsi.h:583
ISCSI_TGT_INVALIDATE_CONNECTION.
Definition: sli4_iscsi.h:988
uint32_t low
Definition: sli4_iscsi.h:241
uint32_t struct_size
Definition: sli4_iscsi.h:74
int32_t sli_cmd_iscsi_common_get_all_if_id(sli4_t *sli4, void *buf, size_t size, uint64_t tag)
write a COMMON_ISCSI_NTWK_GET_ALL_IF_ID command
Definition: sli4_iscsi.c:591
#define SLI4_ISCSI_ACQE_STATELESS_OPERATION_COMPLETE_IPV6
Definition: sli4_iscsi.h:1123
Asynchronouse Event : iSCSI Event - stateless operation complete.
Definition: sli4_iscsi.h:1166
uint32_t ip_type
Definition: sli4_iscsi.h:62
#define SLI4_OPC_ISCSI_TGT_CONNECTION_REJECT
Definition: sli4_iscsi.h:842
COMMON_ISCSI_NTWK_GET_IF_INFO.
Definition: sli4_iscsi.h:541
sli4_ip_addr_t gateway
Definition: sli4_iscsi.h:111
int32_t sli_cmd_iscsi_cleanup_v1(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint16_t ulp_no, uint16_t hdrq_id, uint16_t dataq_id)
write a COMMON_ISCSI_CLEANUP (version 1) command
Definition: sli4_iscsi.c:716
#define SLI4_OPC_ISCSI_TGT_STOP_LISTEN_SERVER
Definition: sli4_iscsi.h:840
SESSION_LOGIN_OPTIONS.
Definition: ocs_common.h:211
This structure is used to track the SLI4 queues.
Definition: sli4.h:2046
uint32_t uint32_t first_burst
Definition: sli4_iscsi.h:121
uint32_t struct_size
Definition: sli4_iscsi.h:62
TARGET_LOGIN_OPTIONS.
Definition: ocs_hal.h:321
#define SLI4_OPC_ISCSI_CFG_REMOVE_SGL_PAGES
Definition: sli4_iscsi.h:167
#define SLI4_OPC_ISCSI_NTWK_GET_ALL_IF_ID
Definition: sli4_iscsi.h:179
uint8_t ip_addr[16]
Definition: sli4_iscsi.h:96
int32_t sli_iscsi_cqe_parse(sli4_t *sli4, sli4_queue_t *cq, uint8_t *cqe, sli4_qentry_fields_t *fields)
Parse a iSCSI work queue CQ entry.
Definition: sli4_iscsi.c:2120
#define SLI4_OPC_ISCSI_DEFQ_CREATE
Definition: sli4_iscsi.h:183
structure wrapping an IP address together with it&#39;s type.
Definition: ocs_hal.h:259
struct sli4_req_common_iscsi_cfg_post_sgl_pages_v1_t::@42 page_set[20]
sli4_target_login_options_t login_options
Definition: sli4_iscsi.h:940
Asynchronouse Event : iSCSI Event.
Definition: sli4_iscsi.h:1131
ISCSI_TGT_STOP_ESI_LISTEN.
Definition: sli4_iscsi.h:1020
int32_t sli_cmd_iscsi_ini_invalidate_connection(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl, uint16_t cid, uint8_t sendRst)
write a ISCSI_INI_INVALIDATE_CONNECTION command
Definition: sli4_iscsi.c:1288
static int32_t sli_iscsi_post_sgl_pages_v0(sli4_t *sli4)
Allocate the SGL pages assigned to the ICD table and post them to the chip.
Definition: sli4_iscsi.c:2358
int32_t __sli_create_queue(sli4_t *sli4, sli4_queue_t *q)
Issue command to create queue.
Definition: sli4.c:3009
sli4_target_login_options_t login_options
Definition: sli4_iscsi.h:962
uint8_t additional_status
Definition: sli4.h:2132
ocs_dma_t bmbx
Definition: sli4.h:2262
uint32_t uint32_t uint32_t uint32_t tcp_window
Definition: sli4_iscsi.h:952
COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR.
Definition: sli4_iscsi.h:331
struct sli4_req_iscsi_wq_create_t::@43 page_physical_address[8]
ISCSI_NTWK_SET_MTU.
Definition: sli4_iscsi.h:651
#define SLI4_OPC_ISCSI_NTWK_GET_ROUTE_TABLE
Definition: sli4_iscsi.h:168
ISCSI_TGT_CONNECTION_REJECT.
Definition: sli4_iscsi.h:913
Asynchronouse Event : iSCSI Event - DHCP operation complete.
Definition: sli4_iscsi.h:1187
int32_t sli_cmd_iscsi_tgt_stop_esi_listen(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *ipaddr, uint32_t tcp_port)
write a ISCSI_TGT_STOP_ESI_LISTEN command
Definition: sli4_iscsi.c:1242
int32_t sli_bmbx_command(sli4_t *sli4)
Submit a command to the bootstrap mailbox and check the status.
Definition: sli4.c:405
#define SLI4_OPC_ISCSI_NTWK_GET_IF_INFO
Definition: sli4_iscsi.h:180
int32_t sli_cmd_iscsi_tgt_offload_connection_v0(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl, uint32_t tcp_window_size, uint16_t ulp_no, uint16_t wq_id, uint16_t cq_id, uint8_t hdrq_id, uint8_t dataq_id, uint8_t nrs, ocs_hal_target_login_options_t *lgn_options)
write a ISCSI_TGT_OFFLOAD_CONNECTION command (version 0)
Definition: sli4_iscsi.c:979
uint16_t num_sges_per_icd
Definition: sli4.h:2241
struct sli4_req_common_iscsi_invalidate_cmds_t::@40 icds[128]
IP_ADDRESS_SUBNET_FORMAT.
Definition: sli4_iscsi.h:91
Scatter-Gather Entry (SGE)
Definition: sli4.h:379
ISCSI_GET_CONNECTION_INFO.
Definition: sli4_iscsi.h:739
#define SLI4_OPC_ISCSI_TGT_OFFLOAD_CONNECTION
Definition: sli4_iscsi.h:843
uint32_t icd_base
Definition: sli4.h:2214
COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY.
Definition: sli4_iscsi.h:511
ocs_hal_ip_type_e sli_iscsi_conv_sli4_ip_addr_type(uint8_t ip_type)
Converts the SLI4 IP address type field to the HAL equivalent value.
Definition: sli4_iscsi.c:342
#define SLI4_OPC_ISCSI_TGT_STOP_ESI_LISTEN
Definition: sli4_iscsi.h:847
void * iscsi_async_arg
Definition: sli4.h:2259
int32_t sli_cmd_iscsi_defq_create(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_dma_t *qmem, uint32_t num_entries, uint16_t cq_id, uint16_t buffer_size, uint16_t ulp)
write a ISCSI_DEFQ_CREATE command
Definition: sli4_iscsi.c:1836
uint32_t uint32_t iface
Definition: sli4_iscsi.h:1189
uint32_t high
Definition: sli4_iscsi.h:242
uint32_t request_length
Definition: sli4.h:589
#define SLI4_ISCSI_ROUTE_TABLE_ENTRY_DEL
Definition: sli4_iscsi.h:414
uint32_t icd_start
Definition: sli4_iscsi.h:259
int32_t sli_cmd_iscsi_common_get_route_table(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_dma_t *dma)
write a COMMON_ISCSI_NTWK_GET_ROUTE_TABLE command
Definition: sli4_iscsi.c:427
Generic Command Request header.
Definition: sli4.h:582
uint32_t icd_num_per_page
Definition: sli4.h:2218
#define SLI4_ISCSI_DEFQ_CREATE_V0_MAX_BUF_SIZE
Definition: sli4_iscsi.h:796
Generic Command Response header.
Definition: sli4.h:600
#define SLI4_OPC_ISCSI_GET_CONNECTION_INFO
Definition: sli4_iscsi.h:190
#define SLI4_OPC_ISCSI_CLEANUP
Definition: sli4_iscsi.h:181
#define SLI4_OPC_ISCSI_DEFQ_DESTROY
Definition: sli4_iscsi.h:184
#define SLI4_OPC_ISCSI_TCP_DISCONNECT
Definition: sli4_iscsi.h:189
ISCSI_TGT_GET_CONNECTION_INFO.
Definition: sli4_iscsi.h:886
int32_t sli_cmd_iscsi_tgt_start_listen_server(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_hal_ip_address_t *ipaddr, uint32_t tcp_port)
write a ISCSI_TGT_START_LISTEN_SERVER command
Definition: sli4_iscsi.c:800
#define SLI4_OPC_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR
Definition: sli4_iscsi.h:172
ISCSI_TGT_STOP_LISTEN_SERVER.
Definition: sli4_iscsi.h:870
#define SLI4_OPC_ISCSI_NTWK_SET_MTU
Definition: sli4_iscsi.h:187
static int32_t sli_iscsi_post_sgl_pages_v1(sli4_t *sli4)
Allocate the SGL pages assigned to the ICD table and post them to the chip.
Definition: sli4_iscsi.c:2468
static int32_t sli_cmd_iscsi_set_fragnum_bits(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t num_bits)
write a COMMON_ISCSI_SET_FRAGNUM_BITS command
Definition: sli4_iscsi.c:760
ocs_session_login_options_t session_options
Definition: ocs_hal.h:322
static int32_t sli_cmd_iscsi_post_sgl_pages_v1(sli4_t *sli4, void *buf, size_t size, uint64_t tag, ocs_dma_t *pages, uint16_t icd_start, uint16_t icd_count)
write a COMMON_ISCSI_CFG_POST_SGL_PAGES (v1) command
Definition: sli4_iscsi.c:2424
int32_t sli_cmd_iscsi_common_iface_create(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t vlan)
write a COMMON_ISCSI_NTWK_IFACE_CREATE command
Definition: sli4_iscsi.c:65
COMMON_ISCSI_NTWK_GET_ALL_IF_ID.
Definition: sli4_iscsi.h:526
int32_t sli_cmd_iscsi_tgt_connection_reject(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t conn_hdl)
write a ISCSI_TGT_CONNECTION_REJECT command
Definition: sli4_iscsi.c:929
ocs_dma_t dma
Definition: sli4.h:2048
#define SLI4_OPC_ISCSI_TGT_ISNS_SEND_PACKET
Definition: sli4_iscsi.h:844
ISCSI_TGT_START_LISTEN_SERVER.
Definition: sli4_iscsi.h:854
#define SLI4_PORT_LINK_STATUS_DOWN
Definition: sli4_iscsi.h:1268
ISCSI_TCP_CONNECT_AND_OFFLOAD.
Definition: sli4_iscsi.h:665
int32_t sli_cmd_iscsi_common_release_stateless_ip_addr(sli4_t *sli4, void *buf, size_t size, uint64_t tag, uint32_t iface, uint8_t isv4)
write a COMMON_ISCSI_NTWK_RELEASE_STATELESS_IP_ADDR command
Definition: sli4_iscsi.c:187