Skip to contentSkip to conversation

ath11k: Cleanup the access code of hw mac_id mapping

PATCH In review Karthikeyan Periyasamy 2 participants 4 messages Jun 10, 2019 – Jun 12, 2019 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath11k: Cleanup the access code of hw mac_id mapping

Added separate function call to get the hw mac id from the pdev index.

---
 drivers/net/wireless/ath/ath11k/ahb.c  |  8 ++++----
 drivers/net/wireless/ath/ath11k/core.c | 23 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/core.h |  4 ++--
 drivers/net/wireless/ath/ath11k/mac.c  |  2 +-
 4 files changed, 30 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath11k/ahb.c +4 -4
index c3e487a..a2c697b 100644
@@ -803,22 +803,22 @@ static int ath11k_ahb_ext_irq_config(struct ath11k_base *sc)
 				if (ath11k_rxdma2host_ring_mask[i] & BIT(j)) {
 					irq_grp->irqs[num_irq++] =
 						rxdma2host_destination_ring_mac1
-						- hw_mac_id_map[j];
+						- ath11k_core_get_hw_mac_id(sc, j);
 				}
 
 				if (ath11k_host2rxdma_ring_mask[i] & BIT(j)) {
 					irq_grp->irqs[num_irq++] =
 						host2rxdma_host_buf_ring_mac1
-						- hw_mac_id_map[j];
+						- ath11k_core_get_hw_mac_id(sc, j);
 				}
 
 				if (rx_mon_status_ring_mask[i] & BIT(j)) {
 					irq_grp->irqs[num_irq++] =
 						ppdu_end_interrupts_mac1 -
-						hw_mac_id_map[j];
+						ath11k_core_get_hw_mac_id(sc, j);
 					irq_grp->irqs[num_irq++] =
 						rxdma2host_monitor_status_ring_mac1 -
-						hw_mac_id_map[j];
+						ath11k_core_get_hw_mac_id(sc, j);
 				}
 			}
 		}
drivers/net/wireless/ath/ath11k/core.c +23 -0
index 928d47b..5655df3 100644
@@ -27,6 +27,29 @@
 			},
 };
 
+/* Map from pdev index to hw mac index */
+u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx)
+{
+	u8 mac_id;
+
+	switch (pdev_idx) {
+	case 0:
+		mac_id = 0;
+		break;
+	case 1:
+		mac_id = 2;
+		break;
+	case 2:
+		mac_id = 1;
+		break;
+	default:
+		mac_id = ATH11K_INVALID_HW_MAC_ID;
+		ath11k_warn(ab, "Invalid pdev idx %d\n", pdev_idx);
+		break;
+	}
+	return mac_id;
+}
+
 static int ath11k_core_create_board_name(struct ath11k_base *sc, char *name,
 					 size_t name_len)
 {
drivers/net/wireless/ath/ath11k/core.h +2 -2
index 7ebb5a4..038f905 100644
@@ -24,8 +24,7 @@
 
 #define ATH11K_TX_MGMT_NUM_PENDING_MAX	512
 
-/* Map from pdev index to hw mac index */
-static const u8 hw_mac_id_map[MAX_RADIOS] = { 0, 2, 1, };
+#define ATH11K_INVALID_HW_MAC_ID	0xFF
 
 enum ath11k_supported_bw {
 	ATH11K_BW_20	= 0,
@@ -828,6 +827,7 @@ struct ieee80211_regdomain *
 int ath11k_regd_update(struct ath11k *ar, bool init);
 int ath11k_reg_update_chan_list(struct ath11k *ar);
 void ath11k_core_halt(struct ath11k *ar);
+u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx);
 
 static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)
 {
drivers/net/wireless/ath/ath11k/mac.c +1 -1
index 13da2e8..ab4670f 100644
@@ -5570,7 +5570,7 @@ int ath11k_mac_create(struct ath11k_base *ab)
 		ar->ab = ab;
 		ar->pdev = pdev;
 		ar->pdev_idx = i;
-		ar->lmac_id = hw_mac_id_map[i];
+		ar->lmac_id = ath11k_core_get_hw_mac_id(ab, i);
 
 		ar->wmi = &ab->wmi_sc.wmi[i];
 		/* FIXME wmi[0] is already initialized during attach,
Signature · 7 lines
1.9.1


_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw
Quoted 3 lines · Karthikeyan Periyasamy

Added separate function call to get the hw mac id from the pdev index.

[...]

Quoted 12 lines
drivers/net/wireless/ath/ath11k/core.c +12 -0
+/* Map from pdev index to hw mac index */
+u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx)
+{
+	u8 mac_id;
+
+	switch (pdev_idx) {
+	case 0:
+		mac_id = 0;
+		break;
+	case 1:
+		mac_id = 2;
+		break;

drivers/net/wireless/ath/ath11k/core.c line 51

Quoted 10 lines
drivers/net/wireless/ath/ath11k/core.c +10 -0
+	case 2:
+		mac_id = 1;
+		break;
+	default:
+		mac_id = ATH11K_INVALID_HW_MAC_ID;
+		ath11k_warn(ab, "Invalid pdev idx %d\n", pdev_idx);
+		break;
+	}
+	return mac_id;
+}

I simplified this function to:

u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx)

{
	switch (pdev_idx) {
	case 0:
		return 0;
	case 1:
		return 2;
	case 2:
		return 1;
	default:
		ath11k_warn(ab, "Invalid pdev idx %d\n", pdev_idx);
		return ATH11K_INVALID_HW_MAC_ID;
	}
}
Signature · 6 lines
Kalle Valo

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#2 lore raw
Quoted 4 lines

I simplified this function to:

u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx)

Quoted 13 lines
{
	switch (pdev_idx) {
	case 0:
		return 0;
	case 1:
		return 2;
	case 2:
		return 1;
	default:
		ath11k_warn(ab, "Invalid pdev idx %d\n", pdev_idx);
		return ATH11K_INVALID_HW_MAC_ID;
	}
}

Look fine to me

Thanks,
Karthikeyan

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

#3 lore raw
In reply to Karthikeyan Periyasamy
Quoted 4 lines · Karthikeyan Periyasamy

Added separate function call to get the hw mac id from the pdev index.

Patch applied to ath11k-bringup branch of ath.git, thanks.

371886ba35ca ath11k: Cleanup the access code of hw mac_id mapping

Signature · 9 lines
https://patchwork.kernel.org/patch/10984583/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k