* Initialize an ULP session. * An ULP session will contain all the resources needed to support rte flow * offloads. A session is initialized as part of rte_eth_device start. * A single vswitch instance can have multiple uplinks which means * rte_eth_device start will be called for each of these devices. * ULP session manager will make sure that a single ULP session is only * initialized once
| 814 | * all opened ULP sessions. |
| 815 | */ |
| 816 | static int32_t |
| 817 | ulp_ctx_session_open(struct bnxt *bp, |
| 818 | struct bnxt_ulp_session_state *session) |
| 819 | { |
| 820 | struct rte_eth_dev *ethdev = bp->eth_dev; |
| 821 | int32_t rc = 0; |
| 822 | struct tf_open_session_parms params; |
| 823 | struct tf_session_resources *resources; |
| 824 | uint32_t ulp_dev_id = BNXT_ULP_DEVICE_ID_LAST; |
| 825 | uint8_t app_id; |
| 826 | struct tf *tfp; |
| 827 | |
| 828 | memset(¶ms, 0, sizeof(params)); |
| 829 | |
| 830 | rc = rte_eth_dev_get_name_by_port(ethdev->data->port_id, |
| 831 | params.ctrl_chan_name); |
| 832 | if (rc) { |
| 833 | BNXT_TF_DBG(ERR, "Invalid port %d, rc = %d\n", |
| 834 | ethdev->data->port_id, rc); |
| 835 | return rc; |
| 836 | } |
| 837 | |
| 838 | rc = bnxt_ulp_cntxt_app_id_get(bp->ulp_ctx, &app_id); |
| 839 | if (rc) { |
| 840 | BNXT_TF_DBG(ERR, "Unable to get the app id from ulp.\n"); |
| 841 | return -EINVAL; |
| 842 | } |
| 843 | |
| 844 | rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &ulp_dev_id); |
| 845 | if (rc) { |
| 846 | BNXT_TF_DBG(ERR, "Unable to get device id from ulp.\n"); |
| 847 | return rc; |
| 848 | } |
| 849 | |
| 850 | params.device_type = bnxt_ulp_cntxt_convert_dev_id(ulp_dev_id); |
| 851 | resources = ¶ms.resources; |
| 852 | rc = bnxt_ulp_tf_resources_get(bp->ulp_ctx, |
| 853 | BNXT_ULP_SESSION_TYPE_DEFAULT, |
| 854 | resources); |
| 855 | if (rc) |
| 856 | return rc; |
| 857 | |
| 858 | params.bp = bp; |
| 859 | |
| 860 | tfp = bnxt_ulp_bp_tfp_get(bp, BNXT_ULP_SESSION_TYPE_DEFAULT); |
| 861 | rc = tf_open_session(tfp, ¶ms); |
| 862 | if (rc) { |
| 863 | BNXT_TF_DBG(ERR, "Failed to open TF session - %s, rc = %d\n", |
| 864 | params.ctrl_chan_name, rc); |
| 865 | return -EINVAL; |
| 866 | } |
| 867 | rc = bnxt_ulp_session_tfp_set(session, |
| 868 | BNXT_ULP_SESSION_TYPE_DEFAULT, tfp); |
| 869 | if (rc) { |
| 870 | BNXT_TF_DBG(ERR, "Failed to set TF session - %s, rc = %d\n", |
| 871 | params.ctrl_chan_name, rc); |
| 872 | return -EINVAL; |
| 873 | } |
no test coverage detected