83 ocs_log_err(hal->os,
"rq_status=%#x: rq_id lookup failed for id=%#x\n", rq_status, rq_id);
88 ocs_log_err(hal->os,
"RCQE status=%#x\n", rq_status);
98 ocs_log_err(hal->os,
"failed to return buffers to RQ\n");
103 hal_rq_t *rq = hal->hal_rq[hal->hal_rq_lookup[rqindex]];
105 rq->rq_empty_warn_count++;
110 hal_rq_t *rq = hal->hal_rq[hal->hal_rq_lookup[rqindex]];
112 rq->rq_empty_err_count++;
122 OCS_STAT({ hal_rq_t *rq = hal->hal_rq[hal->hal_rq_lookup[rqindex]]; rq->use_count++; rq->hdr_use_count++;
123 rq->payload_use_count++;})
131 ocs_log_err(hal->os,
"status=%#x, failed to return marker buffers to RQ\n",
151 if (hal->config.bounce) {
155 uint32_t ox_id = ocs_be16toh(hdr->
ox_id);
156 if (hal->callback.bounce != NULL) {
160 hal->callback.unsolicited(hal->args.unsolicited, seq);
191 uint8_t tow_lock_taken = 0;
192 #if defined(OCS_DISC_SPIN_DELAY)
198 if (0 != rq_status) {
205 ocs_log_err(hal->os,
"status=%#x: rq_id lookup failed for id=%#x\n",
215 ocs_log_err(hal->os,
"status=%#x, failed to return buffers to RQ\n",
223 ocs_log_debug(hal->os,
"Warning: RCQE status=%#x, \n", rq_status);
233 ocs_log_err(hal->os,
"Error: rq_id lookup failed for id=%#x\n", rq_id);
237 OCS_STAT({ hal_rq_t *rq = hal->hal_rq[hal->hal_rq_lookup[rqindex]]; rq->use_count++; rq->hdr_use_count++;
238 rq->payload_use_count++;})
259 ocs_lock(&seq->
hio->tow_lock);
263 seq->
hio->tow_buf->fcfi = seq->
fcfi;
264 seq->
hio->tow_buf->hdr.ox_id = fc_hdr->
ox_id;
265 seq->
hio->tow_buf->hdr.s_id = fc_hdr->
s_id;
266 seq->
hio->tow_buf->hdr.d_id = fc_hdr->
d_id;
267 seq->
hio->tow_buf->cmd_cqe = 1;
278 seq->
hio->tow_buf->call_tow_cmd = TRUE;
279 seq->
hio->tow_buf->cmd_seq = seq;
285 if (hal->config.bounce) {
289 uint32_t ox_id = ocs_be16toh(hdr->
ox_id);
290 if (hal->callback.bounce != NULL) {
294 hal->callback.unsolicited(hal->args.unsolicited, seq);
299 if(seq->
hio->tow_buf->data_cqe == 1) {
301 #if defined(OCS_DISC_SPIN_DELAY)
303 delay = ocs_strtoul(prop_buf, 0, 0);
304 ocs_delay_usec(delay);
308 if (hal->config.bounce) {
312 uint32_t ox_id = ocs_be16toh(hdr->
ox_id);
313 if (hal->callback.bounce != NULL) {
315 &seq->
hio->tow_buf->seq, s_id, d_id, ox_id);
318 hal->callback.unsolicited(hal->args.unsolicited, &seq->
hio->tow_buf->seq);
325 ocs_unlock(&seq->
hio->tow_lock);
351 #if defined(OCS_DISC_SPIN_DELAY)
357 ocs_lock(&io->tow_lock);
384 io->tow_buf->call_tow_data = TRUE;
393 #if defined(OCS_DISC_SPIN_DELAY)
395 delay = ocs_strtoul(prop_buf, 0, 0);
396 ocs_delay_usec(delay);
401 if (hal->config.bounce) {
405 uint32_t ox_id = ocs_be16toh(hdr->
ox_id);
406 if (hal->callback.bounce != NULL) {
410 hal->callback.unsolicited(hal->args.unsolicited, seq);
414 ocs_unlock(&io->tow_lock);
435 hal_rq_t *rq = hal->hal_rq[hal->hal_rq_lookup[rqindex]];
437 #if defined(ENABLE_DEBUG_RQBUF)
439 uint64_t rqbuf_debug_value = 0xdead0000 | ((rq->id & 0xf) << 12) | (bufindex & 0xfff);
442 if (bufindex >= rq_hdr->
length) {
443 ocs_log_err(hal->os,
"RQ index %d bufindex %d exceed ring length %d for id %d\n",
444 rqindex, bufindex, rq_hdr->
length, rq_hdr->
id);
451 #if defined(ENABLE_DEBUG_RQBUF)
453 _sli_queue_poke(&hal->sli, rq_hdr, bufindex, (uint8_t *)&rqbuf_debug_value);
454 _sli_queue_poke(&hal->sli, rq_payload, bufindex, (uint8_t *)&rqbuf_debug_value);
457 seq = rq->rq_tracker[bufindex];
458 rq->rq_tracker[bufindex] = NULL;
461 ocs_log_err(hal->os,
"RQ buffer NULL, rqindex %d, bufindex %d, current q index = %d\n",
462 rqindex, bufindex, rq_hdr->
index);
482 uint32_t hal_rq_index = hal->hal_rq_lookup[seq->
header->
rqindex];
483 hal_rq_t *rq = hal->hal_rq[hal_rq_index];
484 uint32_t phys_hdr[2];
485 uint32_t phys_payload[2];
487 int32_t qindex_payload;
490 phys_hdr[0] = ocs_addr32_hi(seq->
header->
dma.phys);
491 phys_hdr[1] = ocs_addr32_lo(seq->
header->
dma.phys);
492 phys_payload[0] = ocs_addr32_hi(seq->
payload->
dma.phys);
493 phys_payload[1] = ocs_addr32_lo(seq->
payload->
dma.phys);
503 qindex_payload =
_sli_queue_write(&hal->sli, rq_payload, (
void *)phys_payload);
505 if (qindex_hdr < 0 ||
506 qindex_payload < 0) {
507 ocs_log_err(hal->os,
"RQ_ID=%#x write failed\n", rq_hdr->
id);
516 if (rq->rq_tracker[qindex_hdr] == NULL) {
517 rq->rq_tracker[qindex_hdr] = seq;
519 ocs_log_test(hal->os,
"expected rq_tracker[%d][%d] buffer to be NULL\n",
520 hal_rq_index, qindex_hdr);
554 ocs_log_err(hal->os,
"error writing buffers\n");
569 static inline int32_t
594 if (!hal->tow_buffer_pool) {
595 ocs_log_err(hal->os,
"Failed to allocate tow buffer pool\n");
599 for (i = 0; i < num_buffers; i++) {
605 if (ocs_dma_alloc(hal->os, &buf->
payload.
dma, hal->config.tow_io_size,
606 OCS_MIN_DMA_ALIGNMENT)) {
607 ocs_log_err(hal->os,
"Failed to allocate dma buffer\n");
631 ocs_log_info(hal->os,
"Allocated tow buffer pool\n");
649 ocs_lock(&hal->io_lock);
659 ocs_unlock(&hal->io_lock);
703 ocs_dma_t *psgls = &io->def_sgl;
704 ocs_dma_t **sgls = &psgls;
707 post_sgl = ocs_malloc(hal->os, sgl_buf_length, OCS_M_NOWAIT);
708 if (post_sgl == NULL) {
709 ocs_log_err(hal->os,
"no buffer for command\n");
714 io->indicator, 1, sgls, NULL, NULL);
722 ocs_lock(&hal->io_lock);
724 ocs_unlock(&hal->io_lock);
727 ocs_unlock(&hal->io_lock);
743 if (io->tow_buf != NULL) {
744 ocs_lock(&hal->io_lock);
755 ocs_unlock(&hal->io_lock);
785 data = io->def_sgl.virt;
809 if (hal->config.tow_p_type) {
814 diseed->
app_tag_cmp = hal->config.tow_app_tag_value;
891 if (hal->tow_buffer_pool != NULL) {
892 ocs_lock(&hal->io_lock);
899 ocs_unlock(&hal->io_lock);
902 hal->tow_buffer_pool = NULL;
921 uint32_t xris_posted;
928 if (hal->tow_enabled) {
929 if (hal->tow_buffer_pool == NULL) {
945 if (xris_posted != hal->config.tow_xri_cnt) {
946 ocs_log_err(hal->os,
"Post xri failed, only posted %d XRIs\n", xris_posted);
952 ocs_log_debug(hal->os,
"RQ pair init completed\n");
ocs_hal_rtn_e ocs_hal_rqpair_init(ocs_hal_t *hal)
Configure the rq_pair function from ocs_hal_init(). Must be after the IOs are setup and the state is ...
int32_t ocs_hal_io_free(ocs_hal_t *hal, ocs_hal_io_t *io)
Free a previously-allocated HAL IO object.
static int32_t ocs_hal_rqpair_auto_xfer_rdy_move_to_port_cb(ocs_hal_t *hal, int32_t status, uint8_t *mqe, void *arg)
Called when the POST_SGL_PAGE command completes.
#define SLI4_FC_WCQE_STATUS_REMOTE_STOP
static int32_t ocs_list_on_list(ocs_list_link_t *link)
Test if object is on a list.
ocs_hal_rq_buffer_t payload
void ocs_hal_rqpair_tow_move_to_host(ocs_hal_t *hal, ocs_hal_io_t *io)
Prepares an XRI to move back to the host.
void * ocs_pool_get(ocs_pool_t *pool)
Allocate a memory pool item.
static ocs_hal_sequence_t * ocs_hal_rqpair_get(ocs_hal_t *hal, uint16_t rqindex, uint16_t bufindex)
Return pointer to RQ buffer entry.
ocs_hal_rtn_e ocs_hal_rqpair_tow_buffer_alloc(ocs_hal_t *hal, uint32_t num_buffers)
Allocate tow buffers.
ocs_hal_rq_buffer_t * header
static int32_t ocs_list_empty(ocs_list_t *list)
Test if a list is empty.
int32_t ocs_hal_rqpair_process_rq(ocs_hal_t *hal, hal_cq_t *cq, uint8_t *cqe)
Process receive queue completions for RQ Pair mode.
#define FC_FCTL_SEQUENCE_INITIATIVE
void ocs_pool_put(ocs_pool_t *pool, void *item)
free memory pool item
#define SLI4_CQE_CODE_MARKER
T10 DIF Seed Scatter-Gather Entry (SGE)
static void sli_queue_lock(sli4_queue_t *q)
ocs_hal_rq_buffer_t header
int32_t ocs_hal_reque_xri(ocs_hal_t *hal, ocs_hal_io_t *io)
Reque XRI.
#define SLI4_SGE_TYPE_DISEED
#define SLI4_FC_ASYNC_RQ_INSUFF_BUF_FRM_DISC
static uint32_t fc_htobe24(uint32_t x)
int32_t ocs_hal_queue_hash_find(ocs_queue_hash_t *hash, uint16_t id)
Find index given queue ID.
ocs_pool_t * ocs_pool_alloc(ocs_os_handle_t os, uint32_t size, uint32_t count, uint32_t use_lock)
Allocate a memory pool.
void ocs_pool_free(ocs_pool_t *pool)
Free a previously allocated memory pool.
#define FC_FCTL_END_SEQUENCE
#define SLI4_FC_WCQE_STATUS_SUCCESS
FC/FCoE Completion Status Codes.
static void * ocs_list_remove(ocs_list_t *list, void *item)
Remove an item from the list.
ocs_hal_io_t * ocs_hal_io_lookup(ocs_hal_t *hal, uint32_t xri)
Find IO given indicator (xri).
uint8_t ocs_hal_rqpair_tow_xri_buffer_attach(ocs_hal_t *hal, ocs_hal_io_t *io, int reuse_buf)
#define OCS_HAL_RQ_INDEX_DUMMY_HDR
Structure to track optimized write buffers posted to chip owned XRIs.
#define SLI4_FC_ASYNC_RQ_INSUFF_BUF_NEEDED
static int32_t ocs_hal_rqpair_find(ocs_hal_t *hal, uint16_t rq_id)
Find the RQ index of RQ_ID.
static ocs_hal_rtn_e ocs_hal_rqpair_tow_buffer_sequence_reset(ocs_hal_t *hal, ocs_hal_sequence_t *seq)
Return tow buffers (while in RQ pair mode).
#define SLI4_FC_ASYNC_RQ_BUF_LEN_EXCEEDED
static uint32_t sli_get_sgl_preregister(sli4_t *sli4)
#define SLI4_FC_ASYNC_RQ_DMA_FAILURE
static void ocs_hal_rqpair_tow_dnrx_check(ocs_hal_t *hal)
Post Auto xfer rdy buffers to the XRIs posted with DNRX.
#define SLI4_CQE_CODE_OFFSET
void * ocs_pool_get_instance(ocs_pool_t *pool, uint32_t idx)
Return item given an index.
void ocs_pool_reset(ocs_pool_t *pool)
Reset a memory pool.
ocs_hal_rtn_e ocs_hal_rqpair_tow_move_to_port(ocs_hal_t *hal, ocs_hal_io_t *io)
Prepares an XRI to move to the chip.
uint32_t auto_incr_ref_tag
int32_t sli_cmd_fcoe_post_sgl_pages(sli4_t *sli4, void *buf, size_t size, uint16_t xri, uint32_t xri_count, ocs_dma_t *page0[], ocs_dma_t *page1[], ocs_dma_t *dma)
Write an FCOE_POST_SGL_PAGES command.
static void sli_queue_unlock(sli4_queue_t *q)
#define FC_FCTL_EXCHANGE_RESPONDER
ocs_hal_unsol_status_e status
void ocs_hal_unsol_process_bounce(void *arg)
uint32_t ocs_hal_xri_move_to_port_owned(ocs_hal_t *hal, uint32_t num_xri)
Move XRIs from the host-controlled pool to the port.
uint32_t total_data_placed
#define ocs_list_remove_head(list)
Remove and return an item from the head of the list.
static int32_t sli_fc_rqe_length(sli4_t *sli4, void *cqe, uint32_t *len_hdr, uint32_t *len_data)
Retrieve the received header and payload length.
uint32_t buffer_address_low
#define SLI4_SGE_TYPE_DATA
Defines a general FC sequence object, consisting of a header, payload buffers and a HAL IO in the cas...
int32_t _sli_queue_poke(sli4_t *sli4, sli4_queue_t *q, uint32_t index, uint8_t *entry)
#define ocs_hal_assert(cond)
int32_t ocs_hal_rqpair_tow_data_process(ocs_hal_t *hal, hal_cq_t *cq, uint8_t *cqe)
Process CQ completions for Auto xfer rdy data phases.
static uint8_t sli_fc_rqe_fcfi(sli4_t *sli4, void *cqe)
Retrieve the received FCFI.
int32_t ocs_hal_rqpair_tow_cmd_process(ocs_hal_t *hal, hal_cq_t *cq, uint8_t *cqe)
Process receive queue completions for RQ Pair mode - Auto xfer rdy.
uint32_t buffer_address_high
#define FC_FCTL_FIRST_SEQUENCE
int32_t ocs_get_property(const char *prop_name, char *buffer, uint32_t buffer_len)
get driver wide property value
static int32_t ocs_hal_rqpair_put(ocs_hal_t *hal, ocs_hal_sequence_t *seq)
Posts an RQ buffer to a queue and update the verification structures.
Scatter-Gather Entry (SGE)
ocs_hal_rtn_e ocs_hal_rqpair_sequence_free(ocs_hal_t *hal, ocs_hal_sequence_t *seq)
Return RQ buffers (while in RQ pair mode).
ocs_hal_rtn_e ocs_hal_command(ocs_hal_t *hal, uint8_t *cmd, uint32_t opts, void *cb, void *arg)
Issue a SLI command.
static uint32_t fc_be24toh(uint32_t x)
static void ocs_hal_rqpair_tow_buffer_free(ocs_hal_t *hal)
Free tow buffers.
#define SLI4_SGE_TYPE_SKIP
void ocs_hal_rqpair_teardown(ocs_hal_t *hal)
Tear down the rq_pair function from ocs_hal_teardown().
#define OCS_HAL_RQ_INDEX_DUMMY_DATA
#define FC_RCTL_INFO_SOL_DATA
uint32_t ocs_pool_get_count(ocs_pool_t *pool)
Return memory pool item count.
int32_t _sli_queue_write(sli4_t *sli4, sli4_queue_t *q, uint8_t *entry)
Write an entry to the queue object.
ocs_hal_rq_buffer_t * payload
int32_t sli_fc_rqe_rqid_and_index(sli4_t *sli4, uint8_t *cqe, uint16_t *rq_id, uint32_t *index)
Retrieve the RQ index from the completion.
#define FC_FCTL_LAST_SEQUENCE