Commit 1f494387 authored by Sachin D Kulkarni's avatar Sachin D Kulkarni Committed by Anas Nashif
Browse files

nrf_wifi: Remove dependency on OSAL layer handle



Removes the requirement for the different layers in the OS agnostic
parts of the driver having to maintain a handle to the OS interface
layer in order to call the OS interface calls. The OS interface layer
now maitains the handle to OS-specific ops internally and invokes the
appropriate functions.

Fixes SHEL-2639

Signed-off-by: default avatarSachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
parent e085d440
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);

struct nrf_wifi_drv_priv_zep rpu_drv_priv_zep;
extern const struct nrf_wifi_osal_ops nrf_wifi_os_zep_ops;

/* 3 bytes for addreess, 3 bytes for length */
#define MAX_PKT_RAM_TX_ALIGN_OVERHEAD 6
@@ -260,7 +261,7 @@ static void nrf_wifi_process_rssi_from_rx(void *vif_ctx,

	vif_ctx_zep->rssi = MBM_TO_DBM(signal);
	vif_ctx_zep->rssi_record_timestamp_us =
		nrf_wifi_osal_time_get_curr_us(fmac_dev_ctx->fpriv->opriv);
		nrf_wifi_osal_time_get_curr_us();
}
#endif /* CONFIG_NRF70_STA_MODE */

@@ -763,12 +764,22 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
	callbk_fns.get_conn_info_callbk_fn = nrf_wifi_supp_event_proc_get_conn_info;
#endif /* CONFIG_NRF70_STA_MODE */

	/* The OSAL layer needs to be initialized before any other initialization
	 * so that other layers (like FW IF,HW IF etc) have access to OS ops
	 */
	nrf_wifi_osal_init(&nrf_wifi_os_zep_ops);

	rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init(&data_config,
							rx_buf_pools,
							&callbk_fns);
#else /* !CONFIG_NRF70_RADIO_TEST */
	enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;

	/* The OSAL layer needs to be initialized before any other initialization
	 * so that other layers (like FW IF,HW IF etc) have access to OS ops
	 */
	nrf_wifi_osal_init(&nrf_wifi_os_zep_ops);

	rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init_rt();
#endif /* CONFIG_NRF70_RADIO_TEST */

@@ -809,6 +820,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
#ifdef CONFIG_NRF70_RADIO_TEST
fmac_deinit:
	nrf_wifi_fmac_deinit_rt(rpu_drv_priv_zep.fmac_priv);
	nrf_wifi_osal_deinit();
#endif /* CONFIG_NRF70_RADIO_TEST */
err:
	return -1;
+2 −4
Original line number Diff line number Diff line
@@ -487,8 +487,7 @@ enum nrf_wifi_status nrf_wifi_get_mac_addr(struct nrf_wifi_vif_ctx_zep *vif_ctx_
	}
#endif

	if (!nrf_wifi_utils_is_mac_addr_valid(fmac_dev_ctx->fpriv->opriv,
	    vif_ctx_zep->mac_addr.addr)) {
	if (!nrf_wifi_utils_is_mac_addr_valid(vif_ctx_zep->mac_addr.addr)) {
		LOG_ERR("%s: Invalid MAC address: %s",
			__func__,
			net_sprint_ll_addr(vif_ctx_zep->mac_addr.addr,
@@ -682,8 +681,7 @@ int nrf_wifi_if_start_zep(const struct device *dev)
	mac_addr = net_if_get_link_addr(vif_ctx_zep->zep_net_if_ctx)->addr;
	mac_addr_len = net_if_get_link_addr(vif_ctx_zep->zep_net_if_ctx)->len;

	if (!nrf_wifi_utils_is_mac_addr_valid(fmac_dev_ctx->fpriv->opriv,
					      mac_addr)) {
	if (!nrf_wifi_utils_is_mac_addr_valid(mac_addr)) {
		status = nrf_wifi_get_mac_addr(vif_ctx_zep);
		if (status != NRF_WIFI_STATUS_SUCCESS) {
			LOG_ERR("%s: Failed to get MAC address",
+1 −6
Original line number Diff line number Diff line
@@ -872,7 +872,7 @@ static unsigned int zep_shim_strlen(const void *str)
	return strlen(str);
}

static const struct nrf_wifi_osal_ops nrf_wifi_os_zep_ops = {
const struct nrf_wifi_osal_ops nrf_wifi_os_zep_ops = {
	.mem_alloc = zep_shim_mem_alloc,
	.mem_zalloc = zep_shim_mem_zalloc,
	.mem_free = k_free,
@@ -962,8 +962,3 @@ static const struct nrf_wifi_osal_ops nrf_wifi_os_zep_ops = {
	.assert = zep_shim_assert,
	.strlen = zep_shim_strlen,
};

const struct nrf_wifi_osal_ops *get_os_ops(void)
{
	return &nrf_wifi_os_zep_ops;
}
+6 −12
Original line number Diff line number Diff line
@@ -203,15 +203,13 @@ int nrf_wifi_get_power_save_config(const struct device *dev,
	}

	do {
		nrf_wifi_osal_sleep_ms(fmac_dev_ctx->fpriv->opriv,
					1);
		nrf_wifi_osal_sleep_ms(1);
		 count++;
	} while ((vif_ctx_zep->ps_config_info_evnt == false) &&
		 (count < NRF_WIFI_FMAC_PS_CONF_EVNT_RECV_TIMEOUT));

	if (count == NRF_WIFI_FMAC_PS_CONF_EVNT_RECV_TIMEOUT) {
		nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
				      "%s: Timed out",
		nrf_wifi_osal_log_err("%s: Timed out",
				      __func__);
		goto out;
	}
@@ -697,19 +695,16 @@ void nrf_wifi_event_proc_twt_sleep_zep(void *vif_ctx,

	switch (sleep_evnt->info.type) {
	case TWT_BLOCK_TX:
		nrf_wifi_osal_spinlock_take(fmac_dev_ctx->fpriv->opriv,
					    def_dev_ctx->tx_config.tx_lock);
		nrf_wifi_osal_spinlock_take(def_dev_ctx->tx_config.tx_lock);

		def_dev_ctx->twt_sleep_status = NRF_WIFI_FMAC_TWT_STATE_SLEEP;

		wifi_mgmt_raise_twt_sleep_state(vif_ctx_zep->zep_net_if_ctx,
						WIFI_TWT_STATE_SLEEP);
		nrf_wifi_osal_spinlock_rel(fmac_dev_ctx->fpriv->opriv,
					    def_dev_ctx->tx_config.tx_lock);
		nrf_wifi_osal_spinlock_rel(def_dev_ctx->tx_config.tx_lock);
	break;
	case TWT_UNBLOCK_TX:
		nrf_wifi_osal_spinlock_take(fmac_dev_ctx->fpriv->opriv,
					    def_dev_ctx->tx_config.tx_lock);
		nrf_wifi_osal_spinlock_take(def_dev_ctx->tx_config.tx_lock);
		def_dev_ctx->twt_sleep_status = NRF_WIFI_FMAC_TWT_STATE_AWAKE;
		wifi_mgmt_raise_twt_sleep_state(vif_ctx_zep->zep_net_if_ctx,
						WIFI_TWT_STATE_AWAKE);
@@ -722,8 +717,7 @@ void nrf_wifi_event_proc_twt_sleep_zep(void *vif_ctx,
			}
		}
#endif
		nrf_wifi_osal_spinlock_rel(fmac_dev_ctx->fpriv->opriv,
				def_dev_ctx->tx_config.tx_lock);
		nrf_wifi_osal_spinlock_rel(def_dev_ctx->tx_config.tx_lock);
	break;
	default:
	break;
+6 −13
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ int nrf_wifi_disp_scan_zep(const struct device *dev, struct wifi_scan_params *pa
			}

			scan_info->scan_params.center_frequency[k++] = nrf_wifi_utils_chan_to_freq(
				fmac_dev_ctx->fpriv->opriv, band, params->band_chan[i].channel);
				band, params->band_chan[i].channel);

			if (scan_info->scan_params.center_frequency[k - 1] == -1) {
				LOG_ERR("%s: Invalid channel %d", __func__,
@@ -414,23 +414,16 @@ void nrf_wifi_rx_bcn_prb_resp_frm(void *vif_ctx,

	fmac_dev_ctx = rpu_ctx_zep->rpu_ctx;

	frame_length = nrf_wifi_osal_nbuf_data_size(fmac_dev_ctx->fpriv->opriv,
						    nwb);
	frame_length = nrf_wifi_osal_nbuf_data_size(nwb);

	if (frame_length > CONFIG_WIFI_MGMT_RAW_SCAN_RESULT_LENGTH) {
		nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv,
				      &bcn_prb_resp_info.data,
				      nrf_wifi_osal_nbuf_data_get(
						fmac_dev_ctx->fpriv->opriv,
						nwb),
		nrf_wifi_osal_mem_cpy(&bcn_prb_resp_info.data,
				      nrf_wifi_osal_nbuf_data_get(nwb),
				      CONFIG_WIFI_MGMT_RAW_SCAN_RESULT_LENGTH);

	} else {
		nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv,
				      &bcn_prb_resp_info.data,
				      nrf_wifi_osal_nbuf_data_get(
					      fmac_dev_ctx->fpriv->opriv,
					      nwb),
		nrf_wifi_osal_mem_cpy(&bcn_prb_resp_info.data,
				      nrf_wifi_osal_nbuf_data_get(nwb),
				      frame_length);
	}

Loading