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 static_assert(sizeof(struct hwrm_tf_global_cfg_set_input) ==
43 TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET,
44 "HWRM message size changed: hwrm_tf_global_cfg_set_input");
46 #define TF_MSG_SIZE_HWRM_TF_EM_INSERT 104
47 static_assert(sizeof(struct hwrm_tf_em_insert_input) ==
48 TF_MSG_SIZE_HWRM_TF_EM_INSERT,
49 "HWRM message size changed: hwrm_tf_em_insert_input");
51 #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET 128
52 static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==
53 TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET,
54 "HWRM message size changed: hwrm_tf_tbl_type_set_input");
57 * This is the MAX data we can transport across regular HWRM
59 #define TF_PCI_BUF_SIZE_MAX 88
62 * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method
64 struct tf_msg_dma_buf {
70 * Allocates a DMA buffer that can be used for message transfer.
73 * Pointer to DMA buffer structure
76 * Requested size of the buffer in bytes
80 * -ENOMEM - Unable to allocate buffer, no memory
83 tf_msg_alloc_dma_buf(struct tf_msg_dma_buf *buf, int size)
85 struct tfp_calloc_parms alloc_parms;
88 /* Allocate session */
89 alloc_parms.nitems = 1;
90 alloc_parms.size = size;
91 alloc_parms.alignment = 4096;
92 rc = tfp_calloc(&alloc_parms);
96 buf->pa_addr = (uintptr_t)alloc_parms.mem_pa;
97 buf->va_addr = alloc_parms.mem_va;
103 * Free's a previous allocated DMA buffer.
106 * Pointer to DMA buffer structure
109 tf_msg_free_dma_buf(struct tf_msg_dma_buf *buf)
111 tfp_free(buf->va_addr);
114 /* HWRM Direct messages */
117 tf_msg_session_open(struct tf *tfp,
118 char *ctrl_chan_name,
119 uint8_t *fw_session_id,
120 uint8_t *fw_session_client_id,
121 struct tf_dev_info *dev)
124 struct hwrm_tf_session_open_input req = { 0 };
125 struct hwrm_tf_session_open_output resp = { 0 };
126 struct tfp_send_msg_parms parms = { 0 };
128 /* Populate the request */
129 tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
131 parms.tf_type = HWRM_TF_SESSION_OPEN;
132 parms.req_data = (uint32_t *)&req;
133 parms.req_size = sizeof(req);
134 parms.resp_data = (uint32_t *)&resp;
135 parms.resp_size = sizeof(resp);
136 parms.mailbox = dev->ops->tf_dev_get_mailbox();
138 rc = tfp_send_msg_direct(tfp,
143 *fw_session_id = (uint8_t)tfp_le_to_cpu_32(resp.fw_session_id);
144 *fw_session_client_id =
145 (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
151 tf_msg_session_attach(struct tf *tfp __rte_unused,
152 char *ctrl_chan_name __rte_unused,
153 uint8_t tf_fw_session_id __rte_unused)
159 tf_msg_session_client_register(struct tf *tfp,
160 struct tf_session *tfs,
161 char *ctrl_channel_name,
162 uint8_t *fw_session_client_id)
165 struct hwrm_tf_session_register_input req = { 0 };
166 struct hwrm_tf_session_register_output resp = { 0 };
167 struct tfp_send_msg_parms parms = { 0 };
168 uint8_t fw_session_id;
169 struct tf_dev_info *dev;
171 /* Retrieve the device information */
172 rc = tf_session_get_device(tfs, &dev);
175 "Failed to lookup device, rc:%s\n",
180 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
183 "Unable to lookup FW id, rc:%s\n",
188 /* Populate the request */
189 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
190 tfp_memcpy(&req.session_client_name,
192 TF_SESSION_NAME_MAX);
194 parms.tf_type = HWRM_TF_SESSION_REGISTER;
195 parms.req_data = (uint32_t *)&req;
196 parms.req_size = sizeof(req);
197 parms.resp_data = (uint32_t *)&resp;
198 parms.resp_size = sizeof(resp);
199 parms.mailbox = dev->ops->tf_dev_get_mailbox();
201 rc = tfp_send_msg_direct(tfp,
206 *fw_session_client_id =
207 (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
213 tf_msg_session_client_unregister(struct tf *tfp,
214 struct tf_session *tfs,
215 uint8_t fw_session_client_id)
218 struct hwrm_tf_session_unregister_input req = { 0 };
219 struct hwrm_tf_session_unregister_output resp = { 0 };
220 struct tfp_send_msg_parms parms = { 0 };
221 uint8_t fw_session_id;
222 struct tf_dev_info *dev;
224 /* Retrieve the device information */
225 rc = tf_session_get_device(tfs, &dev);
228 "Failed to lookup device, rc:%s\n",
233 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
236 "Unable to lookup FW id, rc:%s\n",
241 /* Populate the request */
242 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
243 req.fw_session_client_id = tfp_cpu_to_le_32(fw_session_client_id);
245 parms.tf_type = HWRM_TF_SESSION_UNREGISTER;
246 parms.req_data = (uint32_t *)&req;
247 parms.req_size = sizeof(req);
248 parms.resp_data = (uint32_t *)&resp;
249 parms.resp_size = sizeof(resp);
250 parms.mailbox = dev->ops->tf_dev_get_mailbox();
252 rc = tfp_send_msg_direct(tfp,
259 tf_msg_session_close(struct tf *tfp,
260 struct tf_session *tfs)
263 struct hwrm_tf_session_close_input req = { 0 };
264 struct hwrm_tf_session_close_output resp = { 0 };
265 struct tfp_send_msg_parms parms = { 0 };
266 uint8_t fw_session_id;
267 struct tf_dev_info *dev;
269 /* Retrieve the device information */
270 rc = tf_session_get_device(tfs, &dev);
273 "Failed to lookup device, rc:%s\n",
278 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
281 "Unable to lookup FW id, rc:%s\n",
286 /* Populate the request */
287 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
289 parms.tf_type = HWRM_TF_SESSION_CLOSE;
290 parms.req_data = (uint32_t *)&req;
291 parms.req_size = sizeof(req);
292 parms.resp_data = (uint32_t *)&resp;
293 parms.resp_size = sizeof(resp);
294 parms.mailbox = dev->ops->tf_dev_get_mailbox();
296 rc = tfp_send_msg_direct(tfp,
302 tf_msg_session_qcfg(struct tf *tfp)
305 struct hwrm_tf_session_qcfg_input req = { 0 };
306 struct hwrm_tf_session_qcfg_output resp = { 0 };
307 struct tfp_send_msg_parms parms = { 0 };
308 uint8_t fw_session_id;
309 struct tf_dev_info *dev;
310 struct tf_session *tfs;
312 /* Retrieve the session information */
313 rc = tf_session_get_session_internal(tfp, &tfs);
316 "Failed to lookup session, rc:%s\n",
321 /* Retrieve the device information */
322 rc = tf_session_get_device(tfs, &dev);
325 "Failed to lookup device, rc:%s\n",
330 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
333 "Unable to lookup FW id, rc:%s\n",
338 /* Populate the request */
339 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
341 parms.tf_type = HWRM_TF_SESSION_QCFG,
342 parms.req_data = (uint32_t *)&req;
343 parms.req_size = sizeof(req);
344 parms.resp_data = (uint32_t *)&resp;
345 parms.resp_size = sizeof(resp);
346 parms.mailbox = dev->ops->tf_dev_get_mailbox();
348 rc = tfp_send_msg_direct(tfp,
354 tf_msg_session_resc_qcaps(struct tf *tfp,
355 struct tf_dev_info *dev,
358 struct tf_rm_resc_req_entry *query,
359 enum tf_rm_resc_resv_strategy *resv_strategy)
363 struct tfp_send_msg_parms parms = { 0 };
364 struct hwrm_tf_session_resc_qcaps_input req = { 0 };
365 struct hwrm_tf_session_resc_qcaps_output resp = { 0 };
366 uint8_t fw_session_id;
367 struct tf_msg_dma_buf qcaps_buf = { 0 };
368 struct tf_rm_resc_req_entry *data;
371 TF_CHECK_PARMS3(tfp, query, resv_strategy);
373 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
376 "%s: Unable to lookup FW id, rc:%s\n",
382 /* Prepare DMA buffer */
383 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
384 rc = tf_msg_alloc_dma_buf(&qcaps_buf, dma_size);
388 /* Populate the request */
389 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
390 req.flags = tfp_cpu_to_le_16(dir);
391 req.qcaps_size = size;
392 req.qcaps_addr = tfp_cpu_to_le_64(qcaps_buf.pa_addr);
394 parms.tf_type = HWRM_TF_SESSION_RESC_QCAPS;
395 parms.req_data = (uint32_t *)&req;
396 parms.req_size = sizeof(req);
397 parms.resp_data = (uint32_t *)&resp;
398 parms.resp_size = sizeof(resp);
399 parms.mailbox = dev->ops->tf_dev_get_mailbox();
401 rc = tfp_send_msg_direct(tfp, &parms);
405 /* Process the response
406 * Should always get expected number of entries
408 if (tfp_le_to_cpu_32(resp.size) != size) {
410 "%s: QCAPS message size error, rc:%s\n",
417 /* Post process the response */
418 data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
419 for (i = 0; i < size; i++) {
420 query[i].type = tfp_le_to_cpu_32(data[i].type);
421 query[i].min = tfp_le_to_cpu_16(data[i].min);
422 query[i].max = tfp_le_to_cpu_16(data[i].max);
425 *resv_strategy = resp.flags &
426 HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK;
429 tf_msg_free_dma_buf(&qcaps_buf);
435 tf_msg_session_resc_alloc(struct tf *tfp,
436 struct tf_dev_info *dev,
439 struct tf_rm_resc_req_entry *request,
440 struct tf_rm_resc_entry *resv)
444 struct tfp_send_msg_parms parms = { 0 };
445 struct hwrm_tf_session_resc_alloc_input req = { 0 };
446 struct hwrm_tf_session_resc_alloc_output resp = { 0 };
447 uint8_t fw_session_id;
448 struct tf_msg_dma_buf req_buf = { 0 };
449 struct tf_msg_dma_buf resv_buf = { 0 };
450 struct tf_rm_resc_req_entry *req_data;
451 struct tf_rm_resc_entry *resv_data;
454 TF_CHECK_PARMS3(tfp, request, resv);
456 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
459 "%s: Unable to lookup FW id, rc:%s\n",
465 /* Prepare DMA buffers */
466 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
467 rc = tf_msg_alloc_dma_buf(&req_buf, dma_size);
471 dma_size = size * sizeof(struct tf_rm_resc_entry);
472 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
474 tf_msg_free_dma_buf(&req_buf);
478 /* Populate the request */
479 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
480 req.flags = tfp_cpu_to_le_16(dir);
483 req_data = (struct tf_rm_resc_req_entry *)req_buf.va_addr;
484 for (i = 0; i < size; i++) {
485 req_data[i].type = tfp_cpu_to_le_32(request[i].type);
486 req_data[i].min = tfp_cpu_to_le_16(request[i].min);
487 req_data[i].max = tfp_cpu_to_le_16(request[i].max);
490 req.req_addr = tfp_cpu_to_le_64(req_buf.pa_addr);
491 req.resc_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
493 parms.tf_type = HWRM_TF_SESSION_RESC_ALLOC;
494 parms.req_data = (uint32_t *)&req;
495 parms.req_size = sizeof(req);
496 parms.resp_data = (uint32_t *)&resp;
497 parms.resp_size = sizeof(resp);
498 parms.mailbox = dev->ops->tf_dev_get_mailbox();
500 rc = tfp_send_msg_direct(tfp, &parms);
504 /* Process the response
505 * Should always get expected number of entries
507 if (tfp_le_to_cpu_32(resp.size) != size) {
509 "%s: Alloc message size error, rc:%s\n",
516 /* Post process the response */
517 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
518 for (i = 0; i < size; i++) {
519 resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
520 resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
521 resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
525 tf_msg_free_dma_buf(&req_buf);
526 tf_msg_free_dma_buf(&resv_buf);
532 tf_msg_session_resc_flush(struct tf *tfp,
535 struct tf_rm_resc_entry *resv)
539 struct tfp_send_msg_parms parms = { 0 };
540 struct hwrm_tf_session_resc_flush_input req = { 0 };
541 struct hwrm_tf_session_resc_flush_output resp = { 0 };
542 uint8_t fw_session_id;
543 struct tf_msg_dma_buf resv_buf = { 0 };
544 struct tf_rm_resc_entry *resv_data;
546 struct tf_dev_info *dev;
547 struct tf_session *tfs;
549 TF_CHECK_PARMS2(tfp, resv);
551 /* Retrieve the session information */
552 rc = tf_session_get_session_internal(tfp, &tfs);
555 "%s: Failed to lookup session, rc:%s\n",
561 /* Retrieve the device information */
562 rc = tf_session_get_device(tfs, &dev);
565 "%s: Failed to lookup device, rc:%s\n",
571 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
574 "%s: Unable to lookup FW id, rc:%s\n",
580 /* Prepare DMA buffers */
581 dma_size = size * sizeof(struct tf_rm_resc_entry);
582 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
586 /* Populate the request */
587 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
588 req.flags = tfp_cpu_to_le_16(dir);
589 req.flush_size = size;
591 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
592 for (i = 0; i < size; i++) {
593 resv_data[i].type = tfp_cpu_to_le_32(resv[i].type);
594 resv_data[i].start = tfp_cpu_to_le_16(resv[i].start);
595 resv_data[i].stride = tfp_cpu_to_le_16(resv[i].stride);
598 req.flush_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
600 parms.tf_type = HWRM_TF_SESSION_RESC_FLUSH;
601 parms.req_data = (uint32_t *)&req;
602 parms.req_size = sizeof(req);
603 parms.resp_data = (uint32_t *)&resp;
604 parms.resp_size = sizeof(resp);
605 parms.mailbox = dev->ops->tf_dev_get_mailbox();
607 rc = tfp_send_msg_direct(tfp, &parms);
609 tf_msg_free_dma_buf(&resv_buf);
615 tf_msg_insert_em_internal_entry(struct tf *tfp,
616 struct tf_insert_em_entry_parms *em_parms,
617 uint16_t *rptr_index,
619 uint8_t *num_of_entries)
622 struct tfp_send_msg_parms parms = { 0 };
623 struct hwrm_tf_em_insert_input req = { 0 };
624 struct hwrm_tf_em_insert_output resp = { 0 };
625 struct tf_em_64b_entry *em_result =
626 (struct tf_em_64b_entry *)em_parms->em_record;
628 uint8_t fw_session_id;
629 uint8_t msg_key_size;
630 struct tf_dev_info *dev;
631 struct tf_session *tfs;
633 /* Retrieve the session information */
634 rc = tf_session_get_session_internal(tfp, &tfs);
637 "%s: Failed to lookup session, rc:%s\n",
638 tf_dir_2_str(em_parms->dir),
643 /* Retrieve the device information */
644 rc = tf_session_get_device(tfs, &dev);
647 "%s: Failed to lookup device, rc:%s\n",
648 tf_dir_2_str(em_parms->dir),
653 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
656 "%s: Unable to lookup FW id, rc:%s\n",
657 tf_dir_2_str(em_parms->dir),
662 /* Populate the request */
663 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
665 /* Check for key size conformity */
666 msg_key_size = (em_parms->key_sz_in_bits + 7) / 8;
667 if (msg_key_size > TF_MSG_EM_INSERT_KEY_SIZE) {
670 "%s: Invalid parameters for msg type, rc:%s\n",
671 tf_dir_2_str(em_parms->dir),
676 tfp_memcpy(req.em_key,
680 flags = (em_parms->dir == TF_DIR_TX ?
681 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
682 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
683 req.flags = tfp_cpu_to_le_16(flags);
684 req.strength = (em_result->hdr.word1 &
685 CFA_P4_EEM_ENTRY_STRENGTH_MASK) >>
686 CFA_P4_EEM_ENTRY_STRENGTH_SHIFT;
687 req.em_key_bitlen = em_parms->key_sz_in_bits;
688 req.action_ptr = em_result->hdr.pointer;
689 req.em_record_idx = *rptr_index;
691 parms.tf_type = HWRM_TF_EM_INSERT;
692 parms.req_data = (uint32_t *)&req;
693 parms.req_size = sizeof(req);
694 parms.resp_data = (uint32_t *)&resp;
695 parms.resp_size = sizeof(resp);
696 parms.mailbox = dev->ops->tf_dev_get_mailbox();
698 rc = tfp_send_msg_direct(tfp,
703 *rptr_entry = resp.rptr_entry;
704 *rptr_index = resp.rptr_index;
705 *num_of_entries = resp.num_of_entries;
711 tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
712 struct tf_insert_em_entry_parms *em_parms,
715 uint16_t *rptr_index,
717 uint8_t *num_of_entries)
720 struct tfp_send_msg_parms parms = { 0 };
721 struct hwrm_tf_em_hash_insert_input req = { 0 };
722 struct hwrm_tf_em_hash_insert_output resp = { 0 };
724 uint8_t fw_session_id;
725 uint8_t msg_record_size;
726 struct tf_dev_info *dev;
727 struct tf_session *tfs;
729 /* Retrieve the session information */
730 rc = tf_session_get_session_internal(tfp, &tfs);
733 "%s: Failed to lookup session, rc:%s\n",
734 tf_dir_2_str(em_parms->dir),
739 /* Retrieve the device information */
740 rc = tf_session_get_device(tfs, &dev);
743 "%s: Failed to lookup device, rc:%s\n",
744 tf_dir_2_str(em_parms->dir),
749 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
752 "%s: Unable to lookup FW id, rc:%s\n",
753 tf_dir_2_str(em_parms->dir),
758 /* Populate the request */
759 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
761 /* Check for key size conformity */
762 msg_record_size = (em_parms->em_record_sz_in_bits + 7) / 8;
764 if (msg_record_size > TF_MSG_EM_INSERT_RECORD_SIZE) {
767 "%s: Record size to large, rc:%s\n",
768 tf_dir_2_str(em_parms->dir),
773 tfp_memcpy((char *)req.em_record,
777 flags = (em_parms->dir == TF_DIR_TX ?
778 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
779 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
780 req.flags = tfp_cpu_to_le_16(flags);
781 req.em_record_size_bits = em_parms->em_record_sz_in_bits;
782 req.em_record_idx = *rptr_index;
783 req.key0_hash = key0_hash;
784 req.key1_hash = key1_hash;
786 parms.tf_type = HWRM_TF_EM_HASH_INSERT;
787 parms.req_data = (uint32_t *)&req;
788 parms.req_size = sizeof(req);
789 parms.resp_data = (uint32_t *)&resp;
790 parms.resp_size = sizeof(resp);
791 parms.mailbox = dev->ops->tf_dev_get_mailbox();
793 rc = tfp_send_msg_direct(tfp,
798 *rptr_entry = resp.rptr_entry;
799 *rptr_index = resp.rptr_index;
800 *num_of_entries = resp.num_of_entries;
806 tf_msg_delete_em_entry(struct tf *tfp,
807 struct tf_delete_em_entry_parms *em_parms)
810 struct tfp_send_msg_parms parms = { 0 };
811 struct hwrm_tf_em_delete_input req = { 0 };
812 struct hwrm_tf_em_delete_output resp = { 0 };
814 uint8_t fw_session_id;
815 struct tf_dev_info *dev;
816 struct tf_session *tfs;
818 /* Retrieve the session information */
819 rc = tf_session_get_session_internal(tfp, &tfs);
822 "%s: Failed to lookup session, rc:%s\n",
823 tf_dir_2_str(em_parms->dir),
828 /* Retrieve the device information */
829 rc = tf_session_get_device(tfs, &dev);
832 "%s: Failed to lookup device, rc:%s\n",
833 tf_dir_2_str(em_parms->dir),
838 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
841 "%s: Unable to lookup FW id, rc:%s\n",
842 tf_dir_2_str(em_parms->dir),
847 /* Populate the request */
848 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
850 flags = (em_parms->dir == TF_DIR_TX ?
851 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX :
852 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX);
853 req.flags = tfp_cpu_to_le_16(flags);
854 req.flow_handle = tfp_cpu_to_le_64(em_parms->flow_handle);
856 parms.tf_type = HWRM_TF_EM_DELETE;
857 parms.req_data = (uint32_t *)&req;
858 parms.req_size = sizeof(req);
859 parms.resp_data = (uint32_t *)&resp;
860 parms.resp_size = sizeof(resp);
861 parms.mailbox = dev->ops->tf_dev_get_mailbox();
863 rc = tfp_send_msg_direct(tfp,
868 em_parms->index = tfp_le_to_cpu_16(resp.em_index);
874 tf_msg_em_mem_rgtr(struct tf *tfp,
881 struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 };
882 struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 };
883 struct tfp_send_msg_parms parms = { 0 };
884 struct tf_dev_info *dev;
885 struct tf_session *tfs;
887 /* Retrieve the session information */
888 rc = tf_session_get_session_internal(tfp, &tfs);
891 "Failed to lookup session, rc:%s\n",
896 /* Retrieve the device information */
897 rc = tf_session_get_device(tfs, &dev);
900 "Failed to lookup device, rc:%s\n",
905 req.page_level = page_lvl;
906 req.page_size = page_size;
907 req.page_dir = tfp_cpu_to_le_64(dma_addr);
909 parms.tf_type = HWRM_TF_CTXT_MEM_RGTR;
910 parms.req_data = (uint32_t *)&req;
911 parms.req_size = sizeof(req);
912 parms.resp_data = (uint32_t *)&resp;
913 parms.resp_size = sizeof(resp);
914 parms.mailbox = dev->ops->tf_dev_get_mailbox();
916 rc = tfp_send_msg_direct(tfp,
921 *ctx_id = tfp_le_to_cpu_16(resp.ctx_id);
927 tf_msg_em_mem_unrgtr(struct tf *tfp,
931 struct hwrm_tf_ctxt_mem_unrgtr_input req = {0};
932 struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0};
933 struct tfp_send_msg_parms parms = { 0 };
934 struct tf_dev_info *dev;
935 struct tf_session *tfs;
937 /* Retrieve the session information */
938 rc = tf_session_get_session_internal(tfp, &tfs);
941 "Failed to lookup session, rc:%s\n",
946 /* Retrieve the device information */
947 rc = tf_session_get_device(tfs, &dev);
950 "Failed to lookup device, rc:%s\n",
955 req.ctx_id = tfp_cpu_to_le_32(*ctx_id);
957 parms.tf_type = HWRM_TF_CTXT_MEM_UNRGTR;
958 parms.req_data = (uint32_t *)&req;
959 parms.req_size = sizeof(req);
960 parms.resp_data = (uint32_t *)&resp;
961 parms.resp_size = sizeof(resp);
962 parms.mailbox = dev->ops->tf_dev_get_mailbox();
964 rc = tfp_send_msg_direct(tfp,
970 tf_msg_em_qcaps(struct tf *tfp,
972 struct tf_em_caps *em_caps)
975 struct hwrm_tf_ext_em_qcaps_input req = {0};
976 struct hwrm_tf_ext_em_qcaps_output resp = { 0 };
978 struct tfp_send_msg_parms parms = { 0 };
979 struct tf_dev_info *dev;
980 struct tf_session *tfs;
982 /* Retrieve the session information */
983 rc = tf_session_get_session_internal(tfp, &tfs);
986 "%s: Failed to lookup session, rc:%s\n",
992 /* Retrieve the device information */
993 rc = tf_session_get_device(tfs, &dev);
996 "%s: Failed to lookup device, rc:%s\n",
1002 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX :
1003 HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX);
1004 req.flags = tfp_cpu_to_le_32(flags);
1006 parms.tf_type = HWRM_TF_EXT_EM_QCAPS;
1007 parms.req_data = (uint32_t *)&req;
1008 parms.req_size = sizeof(req);
1009 parms.resp_data = (uint32_t *)&resp;
1010 parms.resp_size = sizeof(resp);
1011 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1013 rc = tfp_send_msg_direct(tfp,
1018 em_caps->supported = tfp_le_to_cpu_32(resp.supported);
1019 em_caps->max_entries_supported =
1020 tfp_le_to_cpu_32(resp.max_entries_supported);
1021 em_caps->key_entry_size = tfp_le_to_cpu_16(resp.key_entry_size);
1022 em_caps->record_entry_size =
1023 tfp_le_to_cpu_16(resp.record_entry_size);
1024 em_caps->efc_entry_size = tfp_le_to_cpu_16(resp.efc_entry_size);
1030 tf_msg_em_cfg(struct tf *tfp,
1031 uint32_t num_entries,
1032 uint16_t key0_ctx_id,
1033 uint16_t key1_ctx_id,
1034 uint16_t record_ctx_id,
1035 uint16_t efc_ctx_id,
1036 uint8_t flush_interval,
1040 struct hwrm_tf_ext_em_cfg_input req = {0};
1041 struct hwrm_tf_ext_em_cfg_output resp = {0};
1043 struct tfp_send_msg_parms parms = { 0 };
1044 struct tf_dev_info *dev;
1045 struct tf_session *tfs;
1047 /* Retrieve the session information */
1048 rc = tf_session_get_session_internal(tfp, &tfs);
1051 "%s: Failed to lookup session, rc:%s\n",
1057 /* Retrieve the device information */
1058 rc = tf_session_get_device(tfs, &dev);
1061 "%s: Failed to lookup device, rc:%s\n",
1067 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
1068 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
1069 flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD;
1071 req.flags = tfp_cpu_to_le_32(flags);
1072 req.num_entries = tfp_cpu_to_le_32(num_entries);
1074 req.flush_interval = flush_interval;
1076 req.key0_ctx_id = tfp_cpu_to_le_16(key0_ctx_id);
1077 req.key1_ctx_id = tfp_cpu_to_le_16(key1_ctx_id);
1078 req.record_ctx_id = tfp_cpu_to_le_16(record_ctx_id);
1079 req.efc_ctx_id = tfp_cpu_to_le_16(efc_ctx_id);
1081 parms.tf_type = HWRM_TF_EXT_EM_CFG;
1082 parms.req_data = (uint32_t *)&req;
1083 parms.req_size = sizeof(req);
1084 parms.resp_data = (uint32_t *)&resp;
1085 parms.resp_size = sizeof(resp);
1086 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1088 rc = tfp_send_msg_direct(tfp,
1094 tf_msg_em_op(struct tf *tfp,
1099 struct hwrm_tf_ext_em_op_input req = {0};
1100 struct hwrm_tf_ext_em_op_output resp = {0};
1102 struct tfp_send_msg_parms parms = { 0 };
1103 struct tf_dev_info *dev;
1104 struct tf_session *tfs;
1106 /* Retrieve the session information */
1107 rc = tf_session_get_session_internal(tfp, &tfs);
1110 "%s: Failed to lookup session, rc:%s\n",
1116 /* Retrieve the device information */
1117 rc = tf_session_get_device(tfs, &dev);
1120 "%s: Failed to lookup device, rc:%s\n",
1126 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
1127 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
1128 req.flags = tfp_cpu_to_le_32(flags);
1129 req.op = tfp_cpu_to_le_16(op);
1131 parms.tf_type = HWRM_TF_EXT_EM_OP;
1132 parms.req_data = (uint32_t *)&req;
1133 parms.req_size = sizeof(req);
1134 parms.resp_data = (uint32_t *)&resp;
1135 parms.resp_size = sizeof(resp);
1136 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1138 rc = tfp_send_msg_direct(tfp,
1144 tf_msg_tcam_entry_set(struct tf *tfp,
1145 struct tf_dev_info *dev,
1146 struct tf_tcam_set_parms *parms)
1149 struct tfp_send_msg_parms mparms = { 0 };
1150 struct hwrm_tf_tcam_set_input req = { 0 };
1151 struct hwrm_tf_tcam_set_output resp = { 0 };
1152 struct tf_msg_dma_buf buf = { 0 };
1153 uint8_t *data = NULL;
1155 uint8_t fw_session_id;
1157 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1160 "%s: Unable to lookup FW id, rc:%s\n",
1161 tf_dir_2_str(parms->dir),
1166 /* Populate the request */
1167 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1168 req.type = parms->hcapi_type;
1169 req.idx = tfp_cpu_to_le_16(parms->idx);
1170 if (parms->dir == TF_DIR_TX)
1171 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX;
1173 req.key_size = parms->key_size;
1174 req.mask_offset = parms->key_size;
1175 /* Result follows after key and mask, thus multiply by 2 */
1176 req.result_offset = 2 * parms->key_size;
1177 req.result_size = parms->result_size;
1178 data_size = 2 * req.key_size + req.result_size;
1180 if (data_size <= TF_PCI_BUF_SIZE_MAX) {
1181 /* use pci buffer */
1182 data = &req.dev_data[0];
1184 /* use dma buffer */
1185 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
1186 rc = tf_msg_alloc_dma_buf(&buf, data_size);
1190 tfp_memcpy(&req.dev_data[0],
1192 sizeof(buf.pa_addr));
1195 tfp_memcpy(&data[0], parms->key, parms->key_size);
1196 tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
1197 tfp_memcpy(&data[req.result_offset], parms->result, parms->result_size);
1199 mparms.tf_type = HWRM_TF_TCAM_SET;
1200 mparms.req_data = (uint32_t *)&req;
1201 mparms.req_size = sizeof(req);
1202 mparms.resp_data = (uint32_t *)&resp;
1203 mparms.resp_size = sizeof(resp);
1204 mparms.mailbox = dev->ops->tf_dev_get_mailbox();
1206 rc = tfp_send_msg_direct(tfp,
1210 tf_msg_free_dma_buf(&buf);
1216 tf_msg_tcam_entry_get(struct tf *tfp,
1217 struct tf_dev_info *dev,
1218 struct tf_tcam_get_parms *parms)
1221 struct tfp_send_msg_parms mparms = { 0 };
1222 struct hwrm_tf_tcam_get_input req = { 0 };
1223 struct hwrm_tf_tcam_get_output resp = { 0 };
1224 uint8_t fw_session_id;
1226 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1229 "%s: Unable to lookup FW id, rc:%s\n",
1230 tf_dir_2_str(parms->dir),
1235 /* Populate the request */
1236 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1237 req.type = parms->hcapi_type;
1238 req.idx = tfp_cpu_to_le_16(parms->idx);
1239 if (parms->dir == TF_DIR_TX)
1240 req.flags |= HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX;
1242 mparms.tf_type = HWRM_TF_TCAM_GET;
1243 mparms.req_data = (uint32_t *)&req;
1244 mparms.req_size = sizeof(req);
1245 mparms.resp_data = (uint32_t *)&resp;
1246 mparms.resp_size = sizeof(resp);
1247 mparms.mailbox = dev->ops->tf_dev_get_mailbox();
1249 rc = tfp_send_msg_direct(tfp,
1255 if (mparms.tf_resp_code != 0)
1256 return tfp_le_to_cpu_32(mparms.tf_resp_code);
1258 parms->key_size = resp.key_size;
1259 parms->result_size = resp.result_size;
1260 tfp_memcpy(parms->key, resp.dev_data, resp.key_size);
1261 tfp_memcpy(parms->mask, &resp.dev_data[resp.key_size], resp.key_size);
1262 tfp_memcpy(parms->result, &resp.dev_data[resp.result_offset], resp.result_size);
1264 return tfp_le_to_cpu_32(mparms.tf_resp_code);
1268 tf_msg_tcam_entry_free(struct tf *tfp,
1269 struct tf_dev_info *dev,
1270 struct tf_tcam_free_parms *in_parms)
1273 struct hwrm_tf_tcam_free_input req = { 0 };
1274 struct hwrm_tf_tcam_free_output resp = { 0 };
1275 struct tfp_send_msg_parms parms = { 0 };
1276 uint8_t fw_session_id;
1278 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1281 "%s: Unable to lookup FW id, rc:%s\n",
1282 tf_dir_2_str(in_parms->dir),
1287 /* Populate the request */
1288 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1289 req.type = in_parms->hcapi_type;
1291 req.idx_list[0] = tfp_cpu_to_le_16(in_parms->idx);
1292 if (in_parms->dir == TF_DIR_TX)
1293 req.flags |= HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX;
1295 parms.tf_type = HWRM_TF_TCAM_FREE;
1296 parms.req_data = (uint32_t *)&req;
1297 parms.req_size = sizeof(req);
1298 parms.resp_data = (uint32_t *)&resp;
1299 parms.resp_size = sizeof(resp);
1300 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1302 rc = tfp_send_msg_direct(tfp,
1308 tf_msg_set_tbl_entry(struct tf *tfp,
1310 uint16_t hcapi_type,
1316 struct hwrm_tf_tbl_type_set_input req = { 0 };
1317 struct hwrm_tf_tbl_type_set_output resp = { 0 };
1318 struct tfp_send_msg_parms parms = { 0 };
1319 uint8_t fw_session_id;
1320 struct tf_dev_info *dev;
1321 struct tf_session *tfs;
1323 /* Retrieve the session information */
1324 rc = tf_session_get_session_internal(tfp, &tfs);
1327 "%s: Failed to lookup session, rc:%s\n",
1333 /* Retrieve the device information */
1334 rc = tf_session_get_device(tfs, &dev);
1337 "%s: Failed to lookup device, rc:%s\n",
1343 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1346 "%s: Unable to lookup FW id, rc:%s\n",
1352 /* Populate the request */
1353 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1354 req.flags = tfp_cpu_to_le_16(dir);
1355 req.type = tfp_cpu_to_le_32(hcapi_type);
1356 req.size = tfp_cpu_to_le_16(size);
1357 req.index = tfp_cpu_to_le_32(index);
1359 /* Check for data size conformity */
1360 if (size > TF_MSG_TBL_TYPE_SET_DATA_SIZE) {
1363 "%s: Invalid parameters for msg type, rc:%s\n",
1369 tfp_memcpy(&req.data,
1373 parms.tf_type = HWRM_TF_TBL_TYPE_SET;
1374 parms.req_data = (uint32_t *)&req;
1375 parms.req_size = sizeof(req);
1376 parms.resp_data = (uint32_t *)&resp;
1377 parms.resp_size = sizeof(resp);
1378 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1380 rc = tfp_send_msg_direct(tfp,
1385 return tfp_le_to_cpu_32(parms.tf_resp_code);
1389 tf_msg_get_tbl_entry(struct tf *tfp,
1391 uint16_t hcapi_type,
1397 struct hwrm_tf_tbl_type_get_input req = { 0 };
1398 struct hwrm_tf_tbl_type_get_output resp = { 0 };
1399 struct tfp_send_msg_parms parms = { 0 };
1400 uint8_t fw_session_id;
1401 struct tf_dev_info *dev;
1402 struct tf_session *tfs;
1404 /* Retrieve the session information */
1405 rc = tf_session_get_session_internal(tfp, &tfs);
1408 "%s: Failed to lookup session, rc:%s\n",
1414 /* Retrieve the device information */
1415 rc = tf_session_get_device(tfs, &dev);
1418 "%s: Failed to lookup device, rc:%s\n",
1424 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1427 "%s: Unable to lookup FW id, rc:%s\n",
1433 /* Populate the request */
1434 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1435 req.flags = tfp_cpu_to_le_16(dir);
1436 req.type = tfp_cpu_to_le_32(hcapi_type);
1437 req.index = tfp_cpu_to_le_32(index);
1439 parms.tf_type = HWRM_TF_TBL_TYPE_GET;
1440 parms.req_data = (uint32_t *)&req;
1441 parms.req_size = sizeof(req);
1442 parms.resp_data = (uint32_t *)&resp;
1443 parms.resp_size = sizeof(resp);
1444 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1446 rc = tfp_send_msg_direct(tfp,
1451 /* Verify that we got enough buffer to return the requested data */
1452 if (tfp_le_to_cpu_32(resp.size) != size)
1459 return tfp_le_to_cpu_32(parms.tf_resp_code);
1462 /* HWRM Tunneled messages */
1465 tf_msg_get_global_cfg(struct tf *tfp,
1466 struct tf_global_cfg_parms *params)
1469 struct tfp_send_msg_parms parms = { 0 };
1470 struct hwrm_tf_global_cfg_get_input req = { 0 };
1471 struct hwrm_tf_global_cfg_get_output resp = { 0 };
1473 uint8_t fw_session_id;
1474 uint16_t resp_size = 0;
1475 struct tf_dev_info *dev;
1476 struct tf_session *tfs;
1478 /* Retrieve the session information */
1479 rc = tf_session_get_session_internal(tfp, &tfs);
1482 "%s: Failed to lookup session, rc:%s\n",
1483 tf_dir_2_str(params->dir),
1488 /* Retrieve the device information */
1489 rc = tf_session_get_device(tfs, &dev);
1492 "%s: Failed to lookup device, rc:%s\n",
1493 tf_dir_2_str(params->dir),
1498 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1501 "%s: Unable to lookup FW id, rc:%s\n",
1502 tf_dir_2_str(params->dir),
1507 flags = (params->dir == TF_DIR_TX ?
1508 HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX :
1509 HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_RX);
1511 /* Populate the request */
1512 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1513 req.flags = tfp_cpu_to_le_32(flags);
1514 req.type = tfp_cpu_to_le_32(params->type);
1515 req.offset = tfp_cpu_to_le_32(params->offset);
1516 req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
1518 parms.tf_type = HWRM_TF_GLOBAL_CFG_GET;
1519 parms.req_data = (uint32_t *)&req;
1520 parms.req_size = sizeof(req);
1521 parms.resp_data = (uint32_t *)&resp;
1522 parms.resp_size = sizeof(resp);
1523 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1525 rc = tfp_send_msg_direct(tfp, &parms);
1529 /* Verify that we got enough buffer to return the requested data */
1530 resp_size = tfp_le_to_cpu_16(resp.size);
1531 if (resp_size < params->config_sz_in_bytes)
1535 tfp_memcpy(params->config,
1541 return tfp_le_to_cpu_32(parms.tf_resp_code);
1545 tf_msg_set_global_cfg(struct tf *tfp,
1546 struct tf_global_cfg_parms *params)
1549 struct tfp_send_msg_parms parms = { 0 };
1550 struct hwrm_tf_global_cfg_set_input req = { 0 };
1551 struct hwrm_tf_global_cfg_set_output resp = { 0 };
1553 uint8_t fw_session_id;
1554 struct tf_dev_info *dev;
1555 struct tf_session *tfs;
1557 /* Retrieve the session information */
1558 rc = tf_session_get_session_internal(tfp, &tfs);
1561 "%s: Failed to lookup session, rc:%s\n",
1562 tf_dir_2_str(params->dir),
1567 /* Retrieve the device information */
1568 rc = tf_session_get_device(tfs, &dev);
1571 "%s: Failed to lookup device, rc:%s\n",
1572 tf_dir_2_str(params->dir),
1577 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1580 "%s: Unable to lookup FW id, rc:%s\n",
1581 tf_dir_2_str(params->dir),
1586 flags = (params->dir == TF_DIR_TX ?
1587 HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX :
1588 HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_RX);
1590 /* Populate the request */
1591 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1592 req.flags = tfp_cpu_to_le_32(flags);
1593 req.type = tfp_cpu_to_le_32(params->type);
1594 req.offset = tfp_cpu_to_le_32(params->offset);
1596 /* Check for data size conformity */
1597 if (params->config_sz_in_bytes > TF_MSG_SET_GLOBAL_CFG_DATA_SIZE) {
1600 "%s: Invalid parameters for msg type, rc:%s\n",
1601 tf_dir_2_str(params->dir),
1606 tfp_memcpy(req.data, params->config,
1607 params->config_sz_in_bytes);
1609 /* Only set mask if pointer is provided
1611 if (params->config_mask) {
1612 tfp_memcpy(req.mask,
1613 params->config_mask,
1614 params->config_sz_in_bytes);
1617 req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
1619 parms.tf_type = HWRM_TF_GLOBAL_CFG_SET;
1620 parms.req_data = (uint32_t *)&req;
1621 parms.req_size = sizeof(req);
1622 parms.resp_data = (uint32_t *)&resp;
1623 parms.resp_size = sizeof(resp);
1624 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1626 rc = tfp_send_msg_direct(tfp, &parms);
1631 return tfp_le_to_cpu_32(parms.tf_resp_code);
1635 tf_msg_bulk_get_tbl_entry(struct tf *tfp,
1637 uint16_t hcapi_type,
1638 uint32_t starting_idx,
1639 uint16_t num_entries,
1640 uint16_t entry_sz_in_bytes,
1641 uint64_t physical_mem_addr)
1644 struct tfp_send_msg_parms parms = { 0 };
1645 struct tf_tbl_type_bulk_get_input req = { 0 };
1646 struct tf_tbl_type_bulk_get_output resp = { 0 };
1648 uint8_t fw_session_id;
1649 struct tf_dev_info *dev;
1650 struct tf_session *tfs;
1652 /* Retrieve the session information */
1653 rc = tf_session_get_session(tfp, &tfs);
1656 "%s: Failed to lookup session, rc:%s\n",
1662 /* Retrieve the device information */
1663 rc = tf_session_get_device(tfs, &dev);
1666 "%s: Failed to lookup device, rc:%s\n",
1672 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1675 "%s: Unable to lookup FW id, rc:%s\n",
1681 /* Populate the request */
1682 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1683 req.flags = tfp_cpu_to_le_16(dir);
1684 req.type = tfp_cpu_to_le_32(hcapi_type);
1685 req.start_index = tfp_cpu_to_le_32(starting_idx);
1686 req.num_entries = tfp_cpu_to_le_32(num_entries);
1688 data_size = num_entries * entry_sz_in_bytes;
1690 req.host_addr = tfp_cpu_to_le_64(physical_mem_addr);
1693 dev->ops->tf_dev_get_mailbox(),
1695 HWRM_TFT_TBL_TYPE_BULK_GET,
1699 rc = tfp_send_msg_tunneled(tfp, &parms);
1703 /* Verify that we got enough buffer to return the requested data */
1704 if (tfp_le_to_cpu_32(resp.size) != data_size)
1707 return tfp_le_to_cpu_32(parms.tf_resp_code);
1711 tf_msg_get_if_tbl_entry(struct tf *tfp,
1712 struct tf_if_tbl_get_parms *params)
1715 struct tfp_send_msg_parms parms = { 0 };
1716 struct hwrm_tf_if_tbl_get_input req = { 0 };
1717 struct hwrm_tf_if_tbl_get_output resp = { 0 };
1719 struct tf_dev_info *dev;
1720 struct tf_session *tfs;
1722 /* Retrieve the session information */
1723 rc = tf_session_get_session(tfp, &tfs);
1726 "%s: Failed to lookup session, rc:%s\n",
1727 tf_dir_2_str(params->dir),
1732 /* Retrieve the device information */
1733 rc = tf_session_get_device(tfs, &dev);
1736 "%s: Failed to lookup device, rc:%s\n",
1737 tf_dir_2_str(params->dir),
1742 flags = (params->dir == TF_DIR_TX ?
1743 HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX :
1744 HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX);
1746 /* Populate the request */
1748 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
1750 req.type = params->hcapi_type;
1751 req.index = tfp_cpu_to_le_16(params->idx);
1752 req.size = tfp_cpu_to_le_16(params->data_sz_in_bytes);
1754 parms.tf_type = HWRM_TF_IF_TBL_GET;
1755 parms.req_data = (uint32_t *)&req;
1756 parms.req_size = sizeof(req);
1757 parms.resp_data = (uint32_t *)&resp;
1758 parms.resp_size = sizeof(resp);
1759 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1761 rc = tfp_send_msg_direct(tfp, &parms);
1766 if (parms.tf_resp_code != 0)
1767 return tfp_le_to_cpu_32(parms.tf_resp_code);
1769 tfp_memcpy(params->data, resp.data, req.size);
1771 return tfp_le_to_cpu_32(parms.tf_resp_code);
1775 tf_msg_set_if_tbl_entry(struct tf *tfp,
1776 struct tf_if_tbl_set_parms *params)
1779 struct tfp_send_msg_parms parms = { 0 };
1780 struct hwrm_tf_if_tbl_set_input req = { 0 };
1781 struct hwrm_tf_if_tbl_get_output resp = { 0 };
1783 struct tf_dev_info *dev;
1784 struct tf_session *tfs;
1786 /* Retrieve the session information */
1787 rc = tf_session_get_session(tfp, &tfs);
1790 "%s: Failed to lookup session, rc:%s\n",
1791 tf_dir_2_str(params->dir),
1796 /* Retrieve the device information */
1797 rc = tf_session_get_device(tfs, &dev);
1801 flags = (params->dir == TF_DIR_TX ?
1802 HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
1803 HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX);
1805 /* Populate the request */
1807 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
1809 req.type = params->hcapi_type;
1810 req.index = tfp_cpu_to_le_32(params->idx);
1811 req.size = tfp_cpu_to_le_32(params->data_sz_in_bytes);
1812 tfp_memcpy(&req.data[0], params->data, params->data_sz_in_bytes);
1814 parms.tf_type = HWRM_TF_IF_TBL_SET;
1815 parms.req_data = (uint32_t *)&req;
1816 parms.req_size = sizeof(req);
1817 parms.resp_data = (uint32_t *)&resp;
1818 parms.resp_size = sizeof(resp);
1819 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1821 rc = tfp_send_msg_direct(tfp, &parms);
1826 return tfp_le_to_cpu_32(parms.tf_resp_code);