1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2022 Broadcom 3 * All rights reserved. 4 */ 5 #include <stdio.h> 6 #include "tfc.h" 7 #include "tfo.h" 8 #include "tfc_priv.h" 9 #include "bnxt.h" 10 #include "bnxt_ring.h" 11 #include "bnxt_mpc.h" 12 #include "cfa_bld_mpcops.h" 13 #include "cfa_bld_devops.h" 14 15 /* 16 * The tfc_open and tfc_close APIs may only be used for setting TFC software 17 * state. They are never used to modify the HW state. That is, they are not 18 * allowed to send HWRM messages. 19 */ 20 21 int tfc_open(struct tfc *tfcp) 22 { 23 int rc = 0; 24 bool is_pf; 25 26 /* Initialize the TF object */ 27 if (tfcp->tfo) { 28 PMD_DRV_LOG_LINE(WARNING, "tfc_opened already"); 29 return rc; 30 } 31 rc = tfc_bp_is_pf(tfcp, &is_pf); 32 if (rc) 33 return rc; 34 tfo_open(&tfcp->tfo, is_pf); 35 36 return rc; 37 } 38 39 int tfc_close(struct tfc *tfcp) 40 { 41 int rc = 0; 42 uint16_t sid; 43 uint8_t tsid; 44 bool valid; 45 46 /* Nullify the TF object */ 47 if (tfcp->tfo) { 48 if (tfo_sid_get(tfcp->tfo, &sid) == 0) { 49 /* 50 * If no error, then there is a valid SID which means 51 * that the FID is still associated with the SID. 52 */ 53 PMD_DRV_LOG_LINE(WARNING, "There is still a session " 54 "associated with this object"); 55 } 56 57 for (tsid = 0; tsid < TFC_TBL_SCOPE_MAX; tsid++) { 58 rc = tfo_ts_get(tfcp->tfo, tsid, NULL, NULL, &valid, NULL); 59 if (rc == 0 && valid) { 60 PMD_DRV_LOG_LINE(WARNING, "There is still a " 61 "tsid %d associated", 62 tsid); 63 } 64 } 65 tfo_close(&tfcp->tfo); 66 } 67 68 return rc; 69 } 70