1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
12 #include "tf_msg_common.h"
13 #include "tf_device.h"
16 #include "tf_common.h"
17 #include "tf_session.h"
22 /* Specific msg size defines as we cannot use defines in tf.yaml. This
23 * means we have to manually sync hwrm with these defines if the
26 #define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE 16
27 #define TF_MSG_EM_INSERT_KEY_SIZE 64
28 #define TF_MSG_EM_INSERT_RECORD_SIZE 80
29 #define TF_MSG_TBL_TYPE_SET_DATA_SIZE 88
31 /* Compile check - Catch any msg changes that we depend on, like the
32 * defines listed above for array size checking.
34 * Checking array size is dangerous in that the type could change and
35 * we wouldn't be able to catch it. Thus we check if the complete msg
36 * changed instead. Best we can do.
38 * If failure is observed then both msg size (defines below) and the
39 * array size (define above) should be checked and compared.
41 #define TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET 56
42 #define TF_MSG_SIZE_HWRM_TF_EM_INSERT 104
43 #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET 128
46 * This is the MAX data we can transport across regular HWRM
48 #define TF_PCI_BUF_SIZE_MAX 88
51 * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method
53 struct tf_msg_dma_buf {
59 * Allocates a DMA buffer that can be used for message transfer.
62 * Pointer to DMA buffer structure
65 * Requested size of the buffer in bytes
69 * -ENOMEM - Unable to allocate buffer, no memory
72 tf_msg_alloc_dma_buf(struct tf_msg_dma_buf *buf, int size)
74 struct tfp_calloc_parms alloc_parms;
77 /* Allocate session */
78 alloc_parms.nitems = 1;
79 alloc_parms.size = size;
80 alloc_parms.alignment = 4096;
81 rc = tfp_calloc(&alloc_parms);
85 buf->pa_addr = (uintptr_t)alloc_parms.mem_pa;
86 buf->va_addr = alloc_parms.mem_va;
92 * Free's a previous allocated DMA buffer.
95 * Pointer to DMA buffer structure
98 tf_msg_free_dma_buf(struct tf_msg_dma_buf *buf)
100 tfp_free(buf->va_addr);
103 /* HWRM Direct messages */
106 tf_msg_session_open(struct tf *tfp,
107 char *ctrl_chan_name,
108 uint8_t *fw_session_id,
109 uint8_t *fw_session_client_id,
110 struct tf_dev_info *dev)
113 struct hwrm_tf_session_open_input req = { 0 };
114 struct hwrm_tf_session_open_output resp = { 0 };
115 struct tfp_send_msg_parms parms = { 0 };
117 /* Populate the request */
118 tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
120 parms.tf_type = HWRM_TF_SESSION_OPEN;
121 parms.req_data = (uint32_t *)&req;
122 parms.req_size = sizeof(req);
123 parms.resp_data = (uint32_t *)&resp;
124 parms.resp_size = sizeof(resp);
125 parms.mailbox = dev->ops->tf_dev_get_mailbox();
127 rc = tfp_send_msg_direct(tfp,
132 *fw_session_id = (uint8_t)tfp_le_to_cpu_32(resp.fw_session_id);
133 *fw_session_client_id =
134 (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
140 tf_msg_session_attach(struct tf *tfp __rte_unused,
141 char *ctrl_chan_name __rte_unused,
142 uint8_t tf_fw_session_id __rte_unused)
148 tf_msg_session_client_register(struct tf *tfp,
149 struct tf_session *tfs,
150 char *ctrl_channel_name,
151 uint8_t *fw_session_client_id)
154 struct hwrm_tf_session_register_input req = { 0 };
155 struct hwrm_tf_session_register_output resp = { 0 };
156 struct tfp_send_msg_parms parms = { 0 };
157 uint8_t fw_session_id;
158 struct tf_dev_info *dev;
160 /* Retrieve the device information */
161 rc = tf_session_get_device(tfs, &dev);
164 "Failed to lookup device, rc:%s\n",
169 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
172 "Unable to lookup FW id, rc:%s\n",
177 /* Populate the request */
178 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
179 tfp_memcpy(&req.session_client_name,
181 TF_SESSION_NAME_MAX);
183 parms.tf_type = HWRM_TF_SESSION_REGISTER;
184 parms.req_data = (uint32_t *)&req;
185 parms.req_size = sizeof(req);
186 parms.resp_data = (uint32_t *)&resp;
187 parms.resp_size = sizeof(resp);
188 parms.mailbox = dev->ops->tf_dev_get_mailbox();
190 rc = tfp_send_msg_direct(tfp,
195 *fw_session_client_id =
196 (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
202 tf_msg_session_client_unregister(struct tf *tfp,
203 struct tf_session *tfs,
204 uint8_t fw_session_client_id)
207 struct hwrm_tf_session_unregister_input req = { 0 };
208 struct hwrm_tf_session_unregister_output resp = { 0 };
209 struct tfp_send_msg_parms parms = { 0 };
210 uint8_t fw_session_id;
211 struct tf_dev_info *dev;
213 /* Retrieve the device information */
214 rc = tf_session_get_device(tfs, &dev);
217 "Failed to lookup device, rc:%s\n",
222 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
225 "Unable to lookup FW id, rc:%s\n",
230 /* Populate the request */
231 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
232 req.fw_session_client_id = tfp_cpu_to_le_32(fw_session_client_id);
234 parms.tf_type = HWRM_TF_SESSION_UNREGISTER;
235 parms.req_data = (uint32_t *)&req;
236 parms.req_size = sizeof(req);
237 parms.resp_data = (uint32_t *)&resp;
238 parms.resp_size = sizeof(resp);
239 parms.mailbox = dev->ops->tf_dev_get_mailbox();
241 rc = tfp_send_msg_direct(tfp,
248 tf_msg_session_close(struct tf *tfp,
249 struct tf_session *tfs)
252 struct hwrm_tf_session_close_input req = { 0 };
253 struct hwrm_tf_session_close_output resp = { 0 };
254 struct tfp_send_msg_parms parms = { 0 };
255 uint8_t fw_session_id;
256 struct tf_dev_info *dev;
258 /* Retrieve the device information */
259 rc = tf_session_get_device(tfs, &dev);
262 "Failed to lookup device, rc:%s\n",
267 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
270 "Unable to lookup FW id, rc:%s\n",
275 /* Populate the request */
276 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
278 parms.tf_type = HWRM_TF_SESSION_CLOSE;
279 parms.req_data = (uint32_t *)&req;
280 parms.req_size = sizeof(req);
281 parms.resp_data = (uint32_t *)&resp;
282 parms.resp_size = sizeof(resp);
283 parms.mailbox = dev->ops->tf_dev_get_mailbox();
285 rc = tfp_send_msg_direct(tfp,
291 tf_msg_session_qcfg(struct tf *tfp)
294 struct hwrm_tf_session_qcfg_input req = { 0 };
295 struct hwrm_tf_session_qcfg_output resp = { 0 };
296 struct tfp_send_msg_parms parms = { 0 };
297 uint8_t fw_session_id;
298 struct tf_dev_info *dev;
299 struct tf_session *tfs;
301 /* Retrieve the session information */
302 rc = tf_session_get_session_internal(tfp, &tfs);
305 "Failed to lookup session, rc:%s\n",
310 /* Retrieve the device information */
311 rc = tf_session_get_device(tfs, &dev);
314 "Failed to lookup device, rc:%s\n",
319 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
322 "Unable to lookup FW id, rc:%s\n",
327 /* Populate the request */
328 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
330 parms.tf_type = HWRM_TF_SESSION_QCFG,
331 parms.req_data = (uint32_t *)&req;
332 parms.req_size = sizeof(req);
333 parms.resp_data = (uint32_t *)&resp;
334 parms.resp_size = sizeof(resp);
335 parms.mailbox = dev->ops->tf_dev_get_mailbox();
337 rc = tfp_send_msg_direct(tfp,
343 tf_msg_session_resc_qcaps(struct tf *tfp,
344 struct tf_dev_info *dev,
347 struct tf_rm_resc_req_entry *query,
348 enum tf_rm_resc_resv_strategy *resv_strategy)
352 struct tfp_send_msg_parms parms = { 0 };
353 struct hwrm_tf_session_resc_qcaps_input req = { 0 };
354 struct hwrm_tf_session_resc_qcaps_output resp = { 0 };
355 uint8_t fw_session_id;
356 struct tf_msg_dma_buf qcaps_buf = { 0 };
357 struct tf_rm_resc_req_entry *data;
360 TF_CHECK_PARMS3(tfp, query, resv_strategy);
362 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
365 "%s: Unable to lookup FW id, rc:%s\n",
371 /* Prepare DMA buffer */
372 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
373 rc = tf_msg_alloc_dma_buf(&qcaps_buf, dma_size);
377 /* Populate the request */
378 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
379 req.flags = tfp_cpu_to_le_16(dir);
380 req.qcaps_size = size;
381 req.qcaps_addr = tfp_cpu_to_le_64(qcaps_buf.pa_addr);
383 parms.tf_type = HWRM_TF_SESSION_RESC_QCAPS;
384 parms.req_data = (uint32_t *)&req;
385 parms.req_size = sizeof(req);
386 parms.resp_data = (uint32_t *)&resp;
387 parms.resp_size = sizeof(resp);
388 parms.mailbox = dev->ops->tf_dev_get_mailbox();
390 rc = tfp_send_msg_direct(tfp, &parms);
394 /* Process the response
395 * Should always get expected number of entries
397 if (tfp_le_to_cpu_32(resp.size) != size) {
399 "%s: QCAPS message size error, rc:%s\n",
406 /* Post process the response */
407 data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
408 for (i = 0; i < size; i++) {
409 query[i].type = tfp_le_to_cpu_32(data[i].type);
410 query[i].min = tfp_le_to_cpu_16(data[i].min);
411 query[i].max = tfp_le_to_cpu_16(data[i].max);
414 *resv_strategy = resp.flags &
415 HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK;
418 tf_msg_free_dma_buf(&qcaps_buf);
424 tf_msg_session_resc_alloc(struct tf *tfp,
425 struct tf_dev_info *dev,
428 struct tf_rm_resc_req_entry *request,
429 struct tf_rm_resc_entry *resv)
433 struct tfp_send_msg_parms parms = { 0 };
434 struct hwrm_tf_session_resc_alloc_input req = { 0 };
435 struct hwrm_tf_session_resc_alloc_output resp = { 0 };
436 uint8_t fw_session_id;
437 struct tf_msg_dma_buf req_buf = { 0 };
438 struct tf_msg_dma_buf resv_buf = { 0 };
439 struct tf_rm_resc_req_entry *req_data;
440 struct tf_rm_resc_entry *resv_data;
443 TF_CHECK_PARMS3(tfp, request, resv);
445 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
448 "%s: Unable to lookup FW id, rc:%s\n",
454 /* Prepare DMA buffers */
455 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
456 rc = tf_msg_alloc_dma_buf(&req_buf, dma_size);
460 dma_size = size * sizeof(struct tf_rm_resc_entry);
461 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
463 tf_msg_free_dma_buf(&req_buf);
467 /* Populate the request */
468 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
469 req.flags = tfp_cpu_to_le_16(dir);
472 req_data = (struct tf_rm_resc_req_entry *)req_buf.va_addr;
473 for (i = 0; i < size; i++) {
474 req_data[i].type = tfp_cpu_to_le_32(request[i].type);
475 req_data[i].min = tfp_cpu_to_le_16(request[i].min);
476 req_data[i].max = tfp_cpu_to_le_16(request[i].max);
479 req.req_addr = tfp_cpu_to_le_64(req_buf.pa_addr);
480 req.resc_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
482 parms.tf_type = HWRM_TF_SESSION_RESC_ALLOC;
483 parms.req_data = (uint32_t *)&req;
484 parms.req_size = sizeof(req);
485 parms.resp_data = (uint32_t *)&resp;
486 parms.resp_size = sizeof(resp);
487 parms.mailbox = dev->ops->tf_dev_get_mailbox();
489 rc = tfp_send_msg_direct(tfp, &parms);
493 /* Process the response
494 * Should always get expected number of entries
496 if (tfp_le_to_cpu_32(resp.size) != size) {
498 "%s: Alloc message size error, rc:%s\n",
505 /* Post process the response */
506 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
507 for (i = 0; i < size; i++) {
508 resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
509 resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
510 resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
514 tf_msg_free_dma_buf(&req_buf);
515 tf_msg_free_dma_buf(&resv_buf);
521 tf_msg_session_resc_flush(struct tf *tfp,
524 struct tf_rm_resc_entry *resv)
528 struct tfp_send_msg_parms parms = { 0 };
529 struct hwrm_tf_session_resc_flush_input req = { 0 };
530 struct hwrm_tf_session_resc_flush_output resp = { 0 };
531 uint8_t fw_session_id;
532 struct tf_msg_dma_buf resv_buf = { 0 };
533 struct tf_rm_resc_entry *resv_data;
535 struct tf_dev_info *dev;
536 struct tf_session *tfs;
538 TF_CHECK_PARMS2(tfp, resv);
540 /* Retrieve the session information */
541 rc = tf_session_get_session_internal(tfp, &tfs);
544 "%s: Failed to lookup session, rc:%s\n",
550 /* Retrieve the device information */
551 rc = tf_session_get_device(tfs, &dev);
554 "%s: Failed to lookup device, rc:%s\n",
560 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
563 "%s: Unable to lookup FW id, rc:%s\n",
569 /* Prepare DMA buffers */
570 dma_size = size * sizeof(struct tf_rm_resc_entry);
571 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
575 /* Populate the request */
576 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
577 req.flags = tfp_cpu_to_le_16(dir);
578 req.flush_size = size;
580 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
581 for (i = 0; i < size; i++) {
582 resv_data[i].type = tfp_cpu_to_le_32(resv[i].type);
583 resv_data[i].start = tfp_cpu_to_le_16(resv[i].start);
584 resv_data[i].stride = tfp_cpu_to_le_16(resv[i].stride);
587 req.flush_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
589 parms.tf_type = HWRM_TF_SESSION_RESC_FLUSH;
590 parms.req_data = (uint32_t *)&req;
591 parms.req_size = sizeof(req);
592 parms.resp_data = (uint32_t *)&resp;
593 parms.resp_size = sizeof(resp);
594 parms.mailbox = dev->ops->tf_dev_get_mailbox();
596 rc = tfp_send_msg_direct(tfp, &parms);
598 tf_msg_free_dma_buf(&resv_buf);
604 tf_msg_insert_em_internal_entry(struct tf *tfp,
605 struct tf_insert_em_entry_parms *em_parms,
606 uint16_t *rptr_index,
608 uint8_t *num_of_entries)
611 struct tfp_send_msg_parms parms = { 0 };
612 struct hwrm_tf_em_insert_input req = { 0 };
613 struct hwrm_tf_em_insert_output resp = { 0 };
614 struct tf_em_64b_entry *em_result =
615 (struct tf_em_64b_entry *)em_parms->em_record;
617 uint8_t fw_session_id;
618 uint8_t msg_key_size;
619 struct tf_dev_info *dev;
620 struct tf_session *tfs;
622 RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_em_insert_input) !=
623 TF_MSG_SIZE_HWRM_TF_EM_INSERT);
625 /* Retrieve the session information */
626 rc = tf_session_get_session_internal(tfp, &tfs);
629 "%s: Failed to lookup session, rc:%s\n",
630 tf_dir_2_str(em_parms->dir),
635 /* Retrieve the device information */
636 rc = tf_session_get_device(tfs, &dev);
639 "%s: Failed to lookup device, rc:%s\n",
640 tf_dir_2_str(em_parms->dir),
645 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
648 "%s: Unable to lookup FW id, rc:%s\n",
649 tf_dir_2_str(em_parms->dir),
654 /* Populate the request */
655 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
657 /* Check for key size conformity */
658 msg_key_size = (em_parms->key_sz_in_bits + 7) / 8;
659 if (msg_key_size > TF_MSG_EM_INSERT_KEY_SIZE) {
662 "%s: Invalid parameters for msg type, rc:%s\n",
663 tf_dir_2_str(em_parms->dir),
668 tfp_memcpy(req.em_key,
672 flags = (em_parms->dir == TF_DIR_TX ?
673 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
674 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
675 req.flags = tfp_cpu_to_le_16(flags);
676 req.strength = (em_result->hdr.word1 &
677 CFA_P4_EEM_ENTRY_STRENGTH_MASK) >>
678 CFA_P4_EEM_ENTRY_STRENGTH_SHIFT;
679 req.em_key_bitlen = em_parms->key_sz_in_bits;
680 req.action_ptr = em_result->hdr.pointer;
681 req.em_record_idx = *rptr_index;
683 parms.tf_type = HWRM_TF_EM_INSERT;
684 parms.req_data = (uint32_t *)&req;
685 parms.req_size = sizeof(req);
686 parms.resp_data = (uint32_t *)&resp;
687 parms.resp_size = sizeof(resp);
688 parms.mailbox = dev->ops->tf_dev_get_mailbox();
690 rc = tfp_send_msg_direct(tfp,
695 *rptr_entry = resp.rptr_entry;
696 *rptr_index = resp.rptr_index;
697 *num_of_entries = resp.num_of_entries;
703 tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
704 struct tf_insert_em_entry_parms *em_parms,
707 uint16_t *rptr_index,
709 uint8_t *num_of_entries)
712 struct tfp_send_msg_parms parms = { 0 };
713 struct hwrm_tf_em_hash_insert_input req = { 0 };
714 struct hwrm_tf_em_hash_insert_output resp = { 0 };
716 uint8_t fw_session_id;
717 uint8_t msg_record_size;
718 struct tf_dev_info *dev;
719 struct tf_session *tfs;
721 /* Retrieve the session information */
722 rc = tf_session_get_session_internal(tfp, &tfs);
725 "%s: Failed to lookup session, rc:%s\n",
726 tf_dir_2_str(em_parms->dir),
731 /* Retrieve the device information */
732 rc = tf_session_get_device(tfs, &dev);
735 "%s: Failed to lookup device, rc:%s\n",
736 tf_dir_2_str(em_parms->dir),
741 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
744 "%s: Unable to lookup FW id, rc:%s\n",
745 tf_dir_2_str(em_parms->dir),
750 /* Populate the request */
751 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
753 /* Check for key size conformity */
754 msg_record_size = (em_parms->em_record_sz_in_bits + 7) / 8;
756 if (msg_record_size > TF_MSG_EM_INSERT_RECORD_SIZE) {
759 "%s: Record size to large, rc:%s\n",
760 tf_dir_2_str(em_parms->dir),
765 tfp_memcpy((char *)req.em_record,
769 flags = (em_parms->dir == TF_DIR_TX ?
770 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
771 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
772 req.flags = tfp_cpu_to_le_16(flags);
773 req.em_record_size_bits = em_parms->em_record_sz_in_bits;
774 req.em_record_idx = *rptr_index;
775 req.key0_hash = key0_hash;
776 req.key1_hash = key1_hash;
778 parms.tf_type = HWRM_TF_EM_HASH_INSERT;
779 parms.req_data = (uint32_t *)&req;
780 parms.req_size = sizeof(req);
781 parms.resp_data = (uint32_t *)&resp;
782 parms.resp_size = sizeof(resp);
783 parms.mailbox = dev->ops->tf_dev_get_mailbox();
785 rc = tfp_send_msg_direct(tfp,
790 *rptr_entry = resp.rptr_entry;
791 *rptr_index = resp.rptr_index;
792 *num_of_entries = resp.num_of_entries;
798 tf_msg_delete_em_entry(struct tf *tfp,
799 struct tf_delete_em_entry_parms *em_parms)
802 struct tfp_send_msg_parms parms = { 0 };
803 struct hwrm_tf_em_delete_input req = { 0 };
804 struct hwrm_tf_em_delete_output resp = { 0 };
806 uint8_t fw_session_id;
807 struct tf_dev_info *dev;
808 struct tf_session *tfs;
810 /* Retrieve the session information */
811 rc = tf_session_get_session_internal(tfp, &tfs);
814 "%s: Failed to lookup session, rc:%s\n",
815 tf_dir_2_str(em_parms->dir),
820 /* Retrieve the device information */
821 rc = tf_session_get_device(tfs, &dev);
824 "%s: Failed to lookup device, rc:%s\n",
825 tf_dir_2_str(em_parms->dir),
830 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
833 "%s: Unable to lookup FW id, rc:%s\n",
834 tf_dir_2_str(em_parms->dir),
839 /* Populate the request */
840 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
842 flags = (em_parms->dir == TF_DIR_TX ?
843 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX :
844 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX);
845 req.flags = tfp_cpu_to_le_16(flags);
846 req.flow_handle = tfp_cpu_to_le_64(em_parms->flow_handle);
848 parms.tf_type = HWRM_TF_EM_DELETE;
849 parms.req_data = (uint32_t *)&req;
850 parms.req_size = sizeof(req);
851 parms.resp_data = (uint32_t *)&resp;
852 parms.resp_size = sizeof(resp);
853 parms.mailbox = dev->ops->tf_dev_get_mailbox();
855 rc = tfp_send_msg_direct(tfp,
860 em_parms->index = tfp_le_to_cpu_16(resp.em_index);
866 tf_msg_em_mem_rgtr(struct tf *tfp,
873 struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 };
874 struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 };
875 struct tfp_send_msg_parms parms = { 0 };
876 struct tf_dev_info *dev;
877 struct tf_session *tfs;
879 /* Retrieve the session information */
880 rc = tf_session_get_session_internal(tfp, &tfs);
883 "Failed to lookup session, rc:%s\n",
888 /* Retrieve the device information */
889 rc = tf_session_get_device(tfs, &dev);
892 "Failed to lookup device, rc:%s\n",
897 req.page_level = page_lvl;
898 req.page_size = page_size;
899 req.page_dir = tfp_cpu_to_le_64(dma_addr);
901 parms.tf_type = HWRM_TF_CTXT_MEM_RGTR;
902 parms.req_data = (uint32_t *)&req;
903 parms.req_size = sizeof(req);
904 parms.resp_data = (uint32_t *)&resp;
905 parms.resp_size = sizeof(resp);
906 parms.mailbox = dev->ops->tf_dev_get_mailbox();
908 rc = tfp_send_msg_direct(tfp,
913 *ctx_id = tfp_le_to_cpu_16(resp.ctx_id);
919 tf_msg_em_mem_unrgtr(struct tf *tfp,
923 struct hwrm_tf_ctxt_mem_unrgtr_input req = {0};
924 struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0};
925 struct tfp_send_msg_parms parms = { 0 };
926 struct tf_dev_info *dev;
927 struct tf_session *tfs;
929 /* Retrieve the session information */
930 rc = tf_session_get_session_internal(tfp, &tfs);
933 "Failed to lookup session, rc:%s\n",
938 /* Retrieve the device information */
939 rc = tf_session_get_device(tfs, &dev);
942 "Failed to lookup device, rc:%s\n",
947 req.ctx_id = tfp_cpu_to_le_32(*ctx_id);
949 parms.tf_type = HWRM_TF_CTXT_MEM_UNRGTR;
950 parms.req_data = (uint32_t *)&req;
951 parms.req_size = sizeof(req);
952 parms.resp_data = (uint32_t *)&resp;
953 parms.resp_size = sizeof(resp);
954 parms.mailbox = dev->ops->tf_dev_get_mailbox();
956 rc = tfp_send_msg_direct(tfp,
962 tf_msg_em_qcaps(struct tf *tfp,
964 struct tf_em_caps *em_caps)
967 struct hwrm_tf_ext_em_qcaps_input req = {0};
968 struct hwrm_tf_ext_em_qcaps_output resp = { 0 };
970 struct tfp_send_msg_parms parms = { 0 };
971 struct tf_dev_info *dev;
972 struct tf_session *tfs;
974 /* Retrieve the session information */
975 rc = tf_session_get_session_internal(tfp, &tfs);
978 "%s: Failed to lookup session, rc:%s\n",
984 /* Retrieve the device information */
985 rc = tf_session_get_device(tfs, &dev);
988 "%s: Failed to lookup device, rc:%s\n",
994 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX :
995 HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX);
996 req.flags = tfp_cpu_to_le_32(flags);
998 parms.tf_type = HWRM_TF_EXT_EM_QCAPS;
999 parms.req_data = (uint32_t *)&req;
1000 parms.req_size = sizeof(req);
1001 parms.resp_data = (uint32_t *)&resp;
1002 parms.resp_size = sizeof(resp);
1003 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1005 rc = tfp_send_msg_direct(tfp,
1010 em_caps->supported = tfp_le_to_cpu_32(resp.supported);
1011 em_caps->max_entries_supported =
1012 tfp_le_to_cpu_32(resp.max_entries_supported);
1013 em_caps->key_entry_size = tfp_le_to_cpu_16(resp.key_entry_size);
1014 em_caps->record_entry_size =
1015 tfp_le_to_cpu_16(resp.record_entry_size);
1016 em_caps->efc_entry_size = tfp_le_to_cpu_16(resp.efc_entry_size);
1022 tf_msg_em_cfg(struct tf *tfp,
1023 uint32_t num_entries,
1024 uint16_t key0_ctx_id,
1025 uint16_t key1_ctx_id,
1026 uint16_t record_ctx_id,
1027 uint16_t efc_ctx_id,
1028 uint8_t flush_interval,
1032 struct hwrm_tf_ext_em_cfg_input req = {0};
1033 struct hwrm_tf_ext_em_cfg_output resp = {0};
1035 struct tfp_send_msg_parms parms = { 0 };
1036 struct tf_dev_info *dev;
1037 struct tf_session *tfs;
1039 /* Retrieve the session information */
1040 rc = tf_session_get_session_internal(tfp, &tfs);
1043 "%s: Failed to lookup session, rc:%s\n",
1049 /* Retrieve the device information */
1050 rc = tf_session_get_device(tfs, &dev);
1053 "%s: Failed to lookup device, rc:%s\n",
1059 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
1060 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
1061 flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD;
1063 req.flags = tfp_cpu_to_le_32(flags);
1064 req.num_entries = tfp_cpu_to_le_32(num_entries);
1066 req.flush_interval = flush_interval;
1068 req.key0_ctx_id = tfp_cpu_to_le_16(key0_ctx_id);
1069 req.key1_ctx_id = tfp_cpu_to_le_16(key1_ctx_id);
1070 req.record_ctx_id = tfp_cpu_to_le_16(record_ctx_id);
1071 req.efc_ctx_id = tfp_cpu_to_le_16(efc_ctx_id);
1073 parms.tf_type = HWRM_TF_EXT_EM_CFG;
1074 parms.req_data = (uint32_t *)&req;
1075 parms.req_size = sizeof(req);
1076 parms.resp_data = (uint32_t *)&resp;
1077 parms.resp_size = sizeof(resp);
1078 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1080 rc = tfp_send_msg_direct(tfp,
1086 tf_msg_em_op(struct tf *tfp,
1091 struct hwrm_tf_ext_em_op_input req = {0};
1092 struct hwrm_tf_ext_em_op_output resp = {0};
1094 struct tfp_send_msg_parms parms = { 0 };
1095 struct tf_dev_info *dev;
1096 struct tf_session *tfs;
1098 /* Retrieve the session information */
1099 rc = tf_session_get_session_internal(tfp, &tfs);
1102 "%s: Failed to lookup session, rc:%s\n",
1108 /* Retrieve the device information */
1109 rc = tf_session_get_device(tfs, &dev);
1112 "%s: Failed to lookup device, rc:%s\n",
1118 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
1119 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
1120 req.flags = tfp_cpu_to_le_32(flags);
1121 req.op = tfp_cpu_to_le_16(op);
1123 parms.tf_type = HWRM_TF_EXT_EM_OP;
1124 parms.req_data = (uint32_t *)&req;
1125 parms.req_size = sizeof(req);
1126 parms.resp_data = (uint32_t *)&resp;
1127 parms.resp_size = sizeof(resp);
1128 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1130 rc = tfp_send_msg_direct(tfp,
1136 tf_msg_tcam_entry_set(struct tf *tfp,
1137 struct tf_dev_info *dev,
1138 struct tf_tcam_set_parms *parms)
1141 struct tfp_send_msg_parms mparms = { 0 };
1142 struct hwrm_tf_tcam_set_input req = { 0 };
1143 struct hwrm_tf_tcam_set_output resp = { 0 };
1144 struct tf_msg_dma_buf buf = { 0 };
1145 uint8_t *data = NULL;
1147 uint8_t fw_session_id;
1149 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1152 "%s: Unable to lookup FW id, rc:%s\n",
1153 tf_dir_2_str(parms->dir),
1158 /* Populate the request */
1159 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1160 req.type = parms->hcapi_type;
1161 req.idx = tfp_cpu_to_le_16(parms->idx);
1162 if (parms->dir == TF_DIR_TX)
1163 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX;
1165 req.key_size = parms->key_size;
1166 req.mask_offset = parms->key_size;
1167 /* Result follows after key and mask, thus multiply by 2 */
1168 req.result_offset = 2 * parms->key_size;
1169 req.result_size = parms->result_size;
1170 data_size = 2 * req.key_size + req.result_size;
1172 if (data_size <= TF_PCI_BUF_SIZE_MAX) {
1173 /* use pci buffer */
1174 data = &req.dev_data[0];
1176 /* use dma buffer */
1177 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
1178 rc = tf_msg_alloc_dma_buf(&buf, data_size);
1182 tfp_memcpy(&req.dev_data[0],
1184 sizeof(buf.pa_addr));
1187 tfp_memcpy(&data[0], parms->key, parms->key_size);
1188 tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
1189 tfp_memcpy(&data[req.result_offset], parms->result, parms->result_size);
1191 mparms.tf_type = HWRM_TF_TCAM_SET;
1192 mparms.req_data = (uint32_t *)&req;
1193 mparms.req_size = sizeof(req);
1194 mparms.resp_data = (uint32_t *)&resp;
1195 mparms.resp_size = sizeof(resp);
1196 mparms.mailbox = dev->ops->tf_dev_get_mailbox();
1198 rc = tfp_send_msg_direct(tfp,
1202 tf_msg_free_dma_buf(&buf);
1208 tf_msg_tcam_entry_get(struct tf *tfp,
1209 struct tf_dev_info *dev,
1210 struct tf_tcam_get_parms *parms)
1213 struct tfp_send_msg_parms mparms = { 0 };
1214 struct hwrm_tf_tcam_get_input req = { 0 };
1215 struct hwrm_tf_tcam_get_output resp = { 0 };
1216 uint8_t fw_session_id;
1218 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1221 "%s: Unable to lookup FW id, rc:%s\n",
1222 tf_dir_2_str(parms->dir),
1227 /* Populate the request */
1228 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1229 req.type = parms->hcapi_type;
1230 req.idx = tfp_cpu_to_le_16(parms->idx);
1231 if (parms->dir == TF_DIR_TX)
1232 req.flags |= HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX;
1234 mparms.tf_type = HWRM_TF_TCAM_GET;
1235 mparms.req_data = (uint32_t *)&req;
1236 mparms.req_size = sizeof(req);
1237 mparms.resp_data = (uint32_t *)&resp;
1238 mparms.resp_size = sizeof(resp);
1239 mparms.mailbox = dev->ops->tf_dev_get_mailbox();
1241 rc = tfp_send_msg_direct(tfp,
1247 if (mparms.tf_resp_code != 0)
1248 return tfp_le_to_cpu_32(mparms.tf_resp_code);
1250 if (parms->key_size < resp.key_size ||
1251 parms->result_size < resp.result_size) {
1254 "%s: Key buffer(%d) is smaller than the key(%d), rc:%s\n",
1255 tf_dir_2_str(parms->dir),
1261 parms->key_size = resp.key_size;
1262 parms->result_size = resp.result_size;
1263 tfp_memcpy(parms->key, resp.dev_data, resp.key_size);
1264 tfp_memcpy(parms->mask, &resp.dev_data[resp.key_size], resp.key_size);
1265 tfp_memcpy(parms->result, &resp.dev_data[resp.result_offset], resp.result_size);
1267 return tfp_le_to_cpu_32(mparms.tf_resp_code);
1271 tf_msg_tcam_entry_free(struct tf *tfp,
1272 struct tf_dev_info *dev,
1273 struct tf_tcam_free_parms *in_parms)
1276 struct hwrm_tf_tcam_free_input req = { 0 };
1277 struct hwrm_tf_tcam_free_output resp = { 0 };
1278 struct tfp_send_msg_parms parms = { 0 };
1279 uint8_t fw_session_id;
1281 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1284 "%s: Unable to lookup FW id, rc:%s\n",
1285 tf_dir_2_str(in_parms->dir),
1290 /* Populate the request */
1291 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1292 req.type = in_parms->hcapi_type;
1294 req.idx_list[0] = tfp_cpu_to_le_16(in_parms->idx);
1295 if (in_parms->dir == TF_DIR_TX)
1296 req.flags |= HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX;
1298 parms.tf_type = HWRM_TF_TCAM_FREE;
1299 parms.req_data = (uint32_t *)&req;
1300 parms.req_size = sizeof(req);
1301 parms.resp_data = (uint32_t *)&resp;
1302 parms.resp_size = sizeof(resp);
1303 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1305 rc = tfp_send_msg_direct(tfp,
1311 tf_msg_set_tbl_entry(struct tf *tfp,
1313 uint16_t hcapi_type,
1319 struct hwrm_tf_tbl_type_set_input req = { 0 };
1320 struct hwrm_tf_tbl_type_set_output resp = { 0 };
1321 struct tfp_send_msg_parms parms = { 0 };
1322 uint8_t fw_session_id;
1323 struct tf_dev_info *dev;
1324 struct tf_session *tfs;
1326 RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_tbl_type_set_input) !=
1327 TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET);
1329 /* Retrieve the session information */
1330 rc = tf_session_get_session_internal(tfp, &tfs);
1333 "%s: Failed to lookup session, rc:%s\n",
1339 /* Retrieve the device information */
1340 rc = tf_session_get_device(tfs, &dev);
1343 "%s: Failed to lookup device, rc:%s\n",
1349 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1352 "%s: Unable to lookup FW id, rc:%s\n",
1358 /* Populate the request */
1359 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1360 req.flags = tfp_cpu_to_le_16(dir);
1361 req.type = tfp_cpu_to_le_32(hcapi_type);
1362 req.size = tfp_cpu_to_le_16(size);
1363 req.index = tfp_cpu_to_le_32(index);
1365 /* Check for data size conformity */
1366 if (size > TF_MSG_TBL_TYPE_SET_DATA_SIZE) {
1369 "%s: Invalid parameters for msg type, rc:%s\n",
1375 tfp_memcpy(&req.data,
1379 parms.tf_type = HWRM_TF_TBL_TYPE_SET;
1380 parms.req_data = (uint32_t *)&req;
1381 parms.req_size = sizeof(req);
1382 parms.resp_data = (uint32_t *)&resp;
1383 parms.resp_size = sizeof(resp);
1384 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1386 rc = tfp_send_msg_direct(tfp,
1391 return tfp_le_to_cpu_32(parms.tf_resp_code);
1395 tf_msg_get_tbl_entry(struct tf *tfp,
1397 uint16_t hcapi_type,
1403 struct hwrm_tf_tbl_type_get_input req = { 0 };
1404 struct hwrm_tf_tbl_type_get_output resp = { 0 };
1405 struct tfp_send_msg_parms parms = { 0 };
1406 uint8_t fw_session_id;
1407 struct tf_dev_info *dev;
1408 struct tf_session *tfs;
1410 /* Retrieve the session information */
1411 rc = tf_session_get_session_internal(tfp, &tfs);
1414 "%s: Failed to lookup session, rc:%s\n",
1420 /* Retrieve the device information */
1421 rc = tf_session_get_device(tfs, &dev);
1424 "%s: Failed to lookup device, rc:%s\n",
1430 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1433 "%s: Unable to lookup FW id, rc:%s\n",
1439 /* Populate the request */
1440 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1441 req.flags = tfp_cpu_to_le_16(dir);
1442 req.type = tfp_cpu_to_le_32(hcapi_type);
1443 req.index = tfp_cpu_to_le_32(index);
1445 parms.tf_type = HWRM_TF_TBL_TYPE_GET;
1446 parms.req_data = (uint32_t *)&req;
1447 parms.req_size = sizeof(req);
1448 parms.resp_data = (uint32_t *)&resp;
1449 parms.resp_size = sizeof(resp);
1450 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1452 rc = tfp_send_msg_direct(tfp,
1457 /* Verify that we got enough buffer to return the requested data */
1458 if (tfp_le_to_cpu_32(resp.size) != size)
1465 return tfp_le_to_cpu_32(parms.tf_resp_code);
1468 /* HWRM Tunneled messages */
1471 tf_msg_get_global_cfg(struct tf *tfp,
1472 struct tf_global_cfg_parms *params)
1475 struct tfp_send_msg_parms parms = { 0 };
1476 struct hwrm_tf_global_cfg_get_input req = { 0 };
1477 struct hwrm_tf_global_cfg_get_output resp = { 0 };
1479 uint8_t fw_session_id;
1480 uint16_t resp_size = 0;
1481 struct tf_dev_info *dev;
1482 struct tf_session *tfs;
1484 /* Retrieve the session information */
1485 rc = tf_session_get_session_internal(tfp, &tfs);
1488 "%s: Failed to lookup session, rc:%s\n",
1489 tf_dir_2_str(params->dir),
1494 /* Retrieve the device information */
1495 rc = tf_session_get_device(tfs, &dev);
1498 "%s: Failed to lookup device, rc:%s\n",
1499 tf_dir_2_str(params->dir),
1504 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1507 "%s: Unable to lookup FW id, rc:%s\n",
1508 tf_dir_2_str(params->dir),
1513 flags = (params->dir == TF_DIR_TX ?
1514 HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX :
1515 HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_RX);
1517 /* Populate the request */
1518 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1519 req.flags = tfp_cpu_to_le_32(flags);
1520 req.type = tfp_cpu_to_le_32(params->type);
1521 req.offset = tfp_cpu_to_le_32(params->offset);
1522 req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
1524 parms.tf_type = HWRM_TF_GLOBAL_CFG_GET;
1525 parms.req_data = (uint32_t *)&req;
1526 parms.req_size = sizeof(req);
1527 parms.resp_data = (uint32_t *)&resp;
1528 parms.resp_size = sizeof(resp);
1529 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1531 rc = tfp_send_msg_direct(tfp, &parms);
1535 /* Verify that we got enough buffer to return the requested data */
1536 resp_size = tfp_le_to_cpu_16(resp.size);
1537 if (resp_size < params->config_sz_in_bytes)
1541 tfp_memcpy(params->config,
1547 return tfp_le_to_cpu_32(parms.tf_resp_code);
1551 tf_msg_set_global_cfg(struct tf *tfp,
1552 struct tf_global_cfg_parms *params)
1555 struct tfp_send_msg_parms parms = { 0 };
1556 struct hwrm_tf_global_cfg_set_input req = { 0 };
1557 struct hwrm_tf_global_cfg_set_output resp = { 0 };
1559 uint8_t fw_session_id;
1560 struct tf_dev_info *dev;
1561 struct tf_session *tfs;
1563 RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_global_cfg_set_input) !=
1564 TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET);
1566 /* Retrieve the session information */
1567 rc = tf_session_get_session_internal(tfp, &tfs);
1570 "%s: Failed to lookup session, rc:%s\n",
1571 tf_dir_2_str(params->dir),
1576 /* Retrieve the device information */
1577 rc = tf_session_get_device(tfs, &dev);
1580 "%s: Failed to lookup device, rc:%s\n",
1581 tf_dir_2_str(params->dir),
1586 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1589 "%s: Unable to lookup FW id, rc:%s\n",
1590 tf_dir_2_str(params->dir),
1595 flags = (params->dir == TF_DIR_TX ?
1596 HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX :
1597 HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_RX);
1599 /* Populate the request */
1600 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1601 req.flags = tfp_cpu_to_le_32(flags);
1602 req.type = tfp_cpu_to_le_32(params->type);
1603 req.offset = tfp_cpu_to_le_32(params->offset);
1605 /* Check for data size conformity */
1606 if (params->config_sz_in_bytes > TF_MSG_SET_GLOBAL_CFG_DATA_SIZE) {
1609 "%s: Invalid parameters for msg type, rc:%s\n",
1610 tf_dir_2_str(params->dir),
1615 tfp_memcpy(req.data, params->config,
1616 params->config_sz_in_bytes);
1618 /* Only set mask if pointer is provided
1620 if (params->config_mask) {
1621 tfp_memcpy(req.mask,
1622 params->config_mask,
1623 params->config_sz_in_bytes);
1626 req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
1628 parms.tf_type = HWRM_TF_GLOBAL_CFG_SET;
1629 parms.req_data = (uint32_t *)&req;
1630 parms.req_size = sizeof(req);
1631 parms.resp_data = (uint32_t *)&resp;
1632 parms.resp_size = sizeof(resp);
1633 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1635 rc = tfp_send_msg_direct(tfp, &parms);
1640 return tfp_le_to_cpu_32(parms.tf_resp_code);
1644 tf_msg_bulk_get_tbl_entry(struct tf *tfp,
1646 uint16_t hcapi_type,
1647 uint32_t starting_idx,
1648 uint16_t num_entries,
1649 uint16_t entry_sz_in_bytes,
1650 uint64_t physical_mem_addr)
1653 struct tfp_send_msg_parms parms = { 0 };
1654 struct tf_tbl_type_bulk_get_input req = { 0 };
1655 struct tf_tbl_type_bulk_get_output resp = { 0 };
1657 uint8_t fw_session_id;
1658 struct tf_dev_info *dev;
1659 struct tf_session *tfs;
1661 /* Retrieve the session information */
1662 rc = tf_session_get_session(tfp, &tfs);
1665 "%s: Failed to lookup session, rc:%s\n",
1671 /* Retrieve the device information */
1672 rc = tf_session_get_device(tfs, &dev);
1675 "%s: Failed to lookup device, rc:%s\n",
1681 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1684 "%s: Unable to lookup FW id, rc:%s\n",
1690 /* Populate the request */
1691 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1692 req.flags = tfp_cpu_to_le_16(dir);
1693 req.type = tfp_cpu_to_le_32(hcapi_type);
1694 req.start_index = tfp_cpu_to_le_32(starting_idx);
1695 req.num_entries = tfp_cpu_to_le_32(num_entries);
1697 data_size = num_entries * entry_sz_in_bytes;
1699 req.host_addr = tfp_cpu_to_le_64(physical_mem_addr);
1702 dev->ops->tf_dev_get_mailbox(),
1704 HWRM_TFT_TBL_TYPE_BULK_GET,
1708 rc = tfp_send_msg_tunneled(tfp, &parms);
1712 /* Verify that we got enough buffer to return the requested data */
1713 if (tfp_le_to_cpu_32(resp.size) != data_size)
1716 return tfp_le_to_cpu_32(parms.tf_resp_code);
1720 tf_msg_get_if_tbl_entry(struct tf *tfp,
1721 struct tf_if_tbl_get_parms *params)
1724 struct tfp_send_msg_parms parms = { 0 };
1725 struct hwrm_tf_if_tbl_get_input req = { 0 };
1726 struct hwrm_tf_if_tbl_get_output resp = { 0 };
1728 struct tf_dev_info *dev;
1729 struct tf_session *tfs;
1731 /* Retrieve the session information */
1732 rc = tf_session_get_session(tfp, &tfs);
1735 "%s: Failed to lookup session, rc:%s\n",
1736 tf_dir_2_str(params->dir),
1741 /* Retrieve the device information */
1742 rc = tf_session_get_device(tfs, &dev);
1745 "%s: Failed to lookup device, rc:%s\n",
1746 tf_dir_2_str(params->dir),
1751 flags = (params->dir == TF_DIR_TX ?
1752 HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX :
1753 HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX);
1755 /* Populate the request */
1757 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
1759 req.type = params->hcapi_type;
1760 req.index = tfp_cpu_to_le_16(params->idx);
1761 req.size = tfp_cpu_to_le_16(params->data_sz_in_bytes);
1763 parms.tf_type = HWRM_TF_IF_TBL_GET;
1764 parms.req_data = (uint32_t *)&req;
1765 parms.req_size = sizeof(req);
1766 parms.resp_data = (uint32_t *)&resp;
1767 parms.resp_size = sizeof(resp);
1768 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1770 rc = tfp_send_msg_direct(tfp, &parms);
1775 if (parms.tf_resp_code != 0)
1776 return tfp_le_to_cpu_32(parms.tf_resp_code);
1778 tfp_memcpy(params->data, resp.data, req.size);
1780 return tfp_le_to_cpu_32(parms.tf_resp_code);
1784 tf_msg_set_if_tbl_entry(struct tf *tfp,
1785 struct tf_if_tbl_set_parms *params)
1788 struct tfp_send_msg_parms parms = { 0 };
1789 struct hwrm_tf_if_tbl_set_input req = { 0 };
1790 struct hwrm_tf_if_tbl_get_output resp = { 0 };
1792 struct tf_dev_info *dev;
1793 struct tf_session *tfs;
1795 /* Retrieve the session information */
1796 rc = tf_session_get_session(tfp, &tfs);
1799 "%s: Failed to lookup session, rc:%s\n",
1800 tf_dir_2_str(params->dir),
1805 /* Retrieve the device information */
1806 rc = tf_session_get_device(tfs, &dev);
1810 flags = (params->dir == TF_DIR_TX ?
1811 HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
1812 HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX);
1814 /* Populate the request */
1816 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
1818 req.type = params->hcapi_type;
1819 req.index = tfp_cpu_to_le_32(params->idx);
1820 req.size = tfp_cpu_to_le_32(params->data_sz_in_bytes);
1821 tfp_memcpy(&req.data[0], params->data, params->data_sz_in_bytes);
1823 parms.tf_type = HWRM_TF_IF_TBL_SET;
1824 parms.req_data = (uint32_t *)&req;
1825 parms.req_size = sizeof(req);
1826 parms.resp_data = (uint32_t *)&resp;
1827 parms.resp_size = sizeof(resp);
1828 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1830 rc = tfp_send_msg_direct(tfp, &parms);
1835 return tfp_le_to_cpu_32(parms.tf_resp_code);