aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.c56
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.h8
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c67
3 files changed, 62 insertions, 69 deletions
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
index 4745ef2a6f01..9b89ac133946 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -1023,37 +1023,10 @@ ath10k_ce_alloc_dest_ring(struct ath10k *ar, unsigned int ce_id,
1023 * initialized by software/firmware. 1023 * initialized by software/firmware.
1024 */ 1024 */
1025int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id, 1025int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
1026 const struct ce_attr *attr, 1026 const struct ce_attr *attr)
1027 void (*send_cb)(struct ath10k_ce_pipe *),
1028 void (*recv_cb)(struct ath10k_ce_pipe *))
1029{ 1027{
1030 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1031 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1032 int ret; 1028 int ret;
1033 1029
1034 /*
1035 * Make sure there's enough CE ringbuffer entries for HTT TX to avoid
1036 * additional TX locking checks.
1037 *
1038 * For the lack of a better place do the check here.
1039 */
1040 BUILD_BUG_ON(2*TARGET_NUM_MSDU_DESC >
1041 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1));
1042 BUILD_BUG_ON(2*TARGET_10X_NUM_MSDU_DESC >
1043 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1));
1044
1045 spin_lock_bh(&ar_pci->ce_lock);
1046 ce_state->ar = ar;
1047 ce_state->id = ce_id;
1048 ce_state->ctrl_addr = ath10k_ce_base_address(ce_id);
1049 ce_state->attr_flags = attr->flags;
1050 ce_state->src_sz_max = attr->src_sz_max;
1051 if (attr->src_nentries)
1052 ce_state->send_cb = send_cb;
1053 if (attr->dest_nentries)
1054 ce_state->recv_cb = recv_cb;
1055 spin_unlock_bh(&ar_pci->ce_lock);
1056
1057 if (attr->src_nentries) { 1030 if (attr->src_nentries) {
1058 ret = ath10k_ce_init_src_ring(ar, ce_id, attr); 1031 ret = ath10k_ce_init_src_ring(ar, ce_id, attr);
1059 if (ret) { 1032 if (ret) {
@@ -1101,12 +1074,37 @@ void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id)
1101} 1074}
1102 1075
1103int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id, 1076int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
1104 const struct ce_attr *attr) 1077 const struct ce_attr *attr,
1078 void (*send_cb)(struct ath10k_ce_pipe *),
1079 void (*recv_cb)(struct ath10k_ce_pipe *))
1105{ 1080{
1106 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1081 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1107 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id]; 1082 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1108 int ret; 1083 int ret;
1109 1084
1085 /*
1086 * Make sure there's enough CE ringbuffer entries for HTT TX to avoid
1087 * additional TX locking checks.
1088 *
1089 * For the lack of a better place do the check here.
1090 */
1091 BUILD_BUG_ON(2*TARGET_NUM_MSDU_DESC >
1092 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1));
1093 BUILD_BUG_ON(2*TARGET_10X_NUM_MSDU_DESC >
1094 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1));
1095
1096 ce_state->ar = ar;
1097 ce_state->id = ce_id;
1098 ce_state->ctrl_addr = ath10k_ce_base_address(ce_id);
1099 ce_state->attr_flags = attr->flags;
1100 ce_state->src_sz_max = attr->src_sz_max;
1101
1102 if (attr->src_nentries)
1103 ce_state->send_cb = send_cb;
1104
1105 if (attr->dest_nentries)
1106 ce_state->recv_cb = recv_cb;
1107
1110 if (attr->src_nentries) { 1108 if (attr->src_nentries) {
1111 ce_state->src_ring = ath10k_ce_alloc_src_ring(ar, ce_id, attr); 1109 ce_state->src_ring = ath10k_ce_alloc_src_ring(ar, ce_id, attr);
1112 if (IS_ERR(ce_state->src_ring)) { 1110 if (IS_ERR(ce_state->src_ring)) {
diff --git a/drivers/net/wireless/ath/ath10k/ce.h b/drivers/net/wireless/ath/ath10k/ce.h
index 608262ab964e..617a151e8ce4 100644
--- a/drivers/net/wireless/ath/ath10k/ce.h
+++ b/drivers/net/wireless/ath/ath10k/ce.h
@@ -201,12 +201,12 @@ int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
201/*==================CE Engine Initialization=======================*/ 201/*==================CE Engine Initialization=======================*/
202 202
203int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id, 203int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
204 const struct ce_attr *attr, 204 const struct ce_attr *attr);
205 void (*send_cb)(struct ath10k_ce_pipe *),
206 void (*recv_cb)(struct ath10k_ce_pipe *));
207void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id); 205void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id);
208int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id, 206int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
209 const struct ce_attr *attr); 207 const struct ce_attr *attr,
208 void (*send_cb)(struct ath10k_ce_pipe *),
209 void (*recv_cb)(struct ath10k_ce_pipe *));
210void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id); 210void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id);
211 211
212/*==================CE Engine Shutdown=======================*/ 212/*==================CE Engine Shutdown=======================*/
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 243099d62ee9..4a4740b4bdc0 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1615,23 +1615,40 @@ static int ath10k_pci_init_config(struct ath10k *ar)
1615 return 0; 1615 return 0;
1616} 1616}
1617 1617
1618static int ath10k_pci_alloc_ce(struct ath10k *ar) 1618static int ath10k_pci_alloc_pipes(struct ath10k *ar)
1619{ 1619{
1620 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1621 struct ath10k_pci_pipe *pipe;
1620 int i, ret; 1622 int i, ret;
1621 1623
1622 for (i = 0; i < CE_COUNT; i++) { 1624 for (i = 0; i < CE_COUNT; i++) {
1623 ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i]); 1625 pipe = &ar_pci->pipe_info[i];
1626 pipe->ce_hdl = &ar_pci->ce_states[i];
1627 pipe->pipe_num = i;
1628 pipe->hif_ce_state = ar;
1629
1630 ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i],
1631 ath10k_pci_ce_send_done,
1632 ath10k_pci_ce_recv_data);
1624 if (ret) { 1633 if (ret) {
1625 ath10k_err(ar, "failed to allocate copy engine pipe %d: %d\n", 1634 ath10k_err(ar, "failed to allocate copy engine pipe %d: %d\n",
1626 i, ret); 1635 i, ret);
1627 return ret; 1636 return ret;
1628 } 1637 }
1638
1639 /* Last CE is Diagnostic Window */
1640 if (i == CE_COUNT - 1) {
1641 ar_pci->ce_diag = pipe->ce_hdl;
1642 continue;
1643 }
1644
1645 pipe->buf_sz = (size_t)(host_ce_config_wlan[i].src_sz_max);
1629 } 1646 }
1630 1647
1631 return 0; 1648 return 0;
1632} 1649}
1633 1650
1634static void ath10k_pci_free_ce(struct ath10k *ar) 1651static void ath10k_pci_free_pipes(struct ath10k *ar)
1635{ 1652{
1636 int i; 1653 int i;
1637 1654
@@ -1639,39 +1656,17 @@ static void ath10k_pci_free_ce(struct ath10k *ar)
1639 ath10k_ce_free_pipe(ar, i); 1656 ath10k_ce_free_pipe(ar, i);
1640} 1657}
1641 1658
1642static int ath10k_pci_ce_init(struct ath10k *ar) 1659static int ath10k_pci_init_pipes(struct ath10k *ar)
1643{ 1660{
1644 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1661 int i, ret;
1645 struct ath10k_pci_pipe *pipe_info;
1646 const struct ce_attr *attr;
1647 int pipe_num, ret;
1648 1662
1649 for (pipe_num = 0; pipe_num < CE_COUNT; pipe_num++) { 1663 for (i = 0; i < CE_COUNT; i++) {
1650 pipe_info = &ar_pci->pipe_info[pipe_num]; 1664 ret = ath10k_ce_init_pipe(ar, i, &host_ce_config_wlan[i]);
1651 pipe_info->ce_hdl = &ar_pci->ce_states[pipe_num];
1652 pipe_info->pipe_num = pipe_num;
1653 pipe_info->hif_ce_state = ar;
1654 attr = &host_ce_config_wlan[pipe_num];
1655
1656 ret = ath10k_ce_init_pipe(ar, pipe_num, attr,
1657 ath10k_pci_ce_send_done,
1658 ath10k_pci_ce_recv_data);
1659 if (ret) { 1665 if (ret) {
1660 ath10k_err(ar, "failed to initialize copy engine pipe %d: %d\n", 1666 ath10k_err(ar, "failed to initialize copy engine pipe %d: %d\n",
1661 pipe_num, ret); 1667 i, ret);
1662 return ret; 1668 return ret;
1663 } 1669 }
1664
1665 if (pipe_num == CE_COUNT - 1) {
1666 /*
1667 * Reserve the ultimate CE for
1668 * diagnostic Window support
1669 */
1670 ar_pci->ce_diag = pipe_info->ce_hdl;
1671 continue;
1672 }
1673
1674 pipe_info->buf_sz = (size_t)(attr->src_sz_max);
1675 } 1670 }
1676 1671
1677 return 0; 1672 return 0;
@@ -1825,7 +1820,7 @@ static int __ath10k_pci_hif_power_up(struct ath10k *ar, bool cold_reset)
1825 goto err; 1820 goto err;
1826 } 1821 }
1827 1822
1828 ret = ath10k_pci_ce_init(ar); 1823 ret = ath10k_pci_init_pipes(ar);
1829 if (ret) { 1824 if (ret) {
1830 ath10k_err(ar, "failed to initialize CE: %d\n", ret); 1825 ath10k_err(ar, "failed to initialize CE: %d\n", ret);
1831 goto err; 1826 goto err;
@@ -2495,7 +2490,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2495 goto err_sleep; 2490 goto err_sleep;
2496 } 2491 }
2497 2492
2498 ret = ath10k_pci_alloc_ce(ar); 2493 ret = ath10k_pci_alloc_pipes(ar);
2499 if (ret) { 2494 if (ret) {
2500 ath10k_err(ar, "failed to allocate copy engine pipes: %d\n", 2495 ath10k_err(ar, "failed to allocate copy engine pipes: %d\n",
2501 ret); 2496 ret);
@@ -2508,7 +2503,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2508 ret = ath10k_pci_init_irq(ar); 2503 ret = ath10k_pci_init_irq(ar);
2509 if (ret) { 2504 if (ret) {
2510 ath10k_err(ar, "failed to init irqs: %d\n", ret); 2505 ath10k_err(ar, "failed to init irqs: %d\n", ret);
2511 goto err_free_ce; 2506 goto err_free_pipes;
2512 } 2507 }
2513 2508
2514 ath10k_info(ar, "pci irq %s interrupts %d irq_mode %d reset_mode %d\n", 2509 ath10k_info(ar, "pci irq %s interrupts %d irq_mode %d reset_mode %d\n",
@@ -2536,8 +2531,8 @@ err_free_irq:
2536err_deinit_irq: 2531err_deinit_irq:
2537 ath10k_pci_deinit_irq(ar); 2532 ath10k_pci_deinit_irq(ar);
2538 2533
2539err_free_ce: 2534err_free_pipes:
2540 ath10k_pci_free_ce(ar); 2535 ath10k_pci_free_pipes(ar);
2541 2536
2542err_sleep: 2537err_sleep:
2543 ath10k_pci_sleep(ar); 2538 ath10k_pci_sleep(ar);
@@ -2571,7 +2566,7 @@ static void ath10k_pci_remove(struct pci_dev *pdev)
2571 ath10k_pci_kill_tasklet(ar); 2566 ath10k_pci_kill_tasklet(ar);
2572 ath10k_pci_deinit_irq(ar); 2567 ath10k_pci_deinit_irq(ar);
2573 ath10k_pci_ce_deinit(ar); 2568 ath10k_pci_ce_deinit(ar);
2574 ath10k_pci_free_ce(ar); 2569 ath10k_pci_free_pipes(ar);
2575 ath10k_pci_sleep(ar); 2570 ath10k_pci_sleep(ar);
2576 ath10k_pci_release(ar); 2571 ath10k_pci_release(ar);
2577 ath10k_core_destroy(ar); 2572 ath10k_core_destroy(ar);