Commit 48cc2f5e authored by Haijun Liu's avatar Haijun Liu Committed by David S. Miller

net: wwan: t7xx: Add port proxy infrastructure

Port-proxy provides a common interface to interact with different types
of ports. Ports export their configuration via `struct t7xx_port` and
operate as defined by `struct port_ops`.
Signed-off-by: default avatarHaijun Liu <haijun.liu@mediatek.com>
Co-developed-by: default avatarChandrashekar Devegowda <chandrashekar.devegowda@intel.com>
Signed-off-by: default avatarChandrashekar Devegowda <chandrashekar.devegowda@intel.com>
Co-developed-by: default avatarRicardo Martinez <ricardo.martinez@linux.intel.com>
Signed-off-by: default avatarRicardo Martinez <ricardo.martinez@linux.intel.com>
Reviewed-by: default avatarLoic Poulain <loic.poulain@linaro.org>
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: default avatarSergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 13e920d9
......@@ -10,3 +10,4 @@ mtk_t7xx-y:= t7xx_pci.o \
t7xx_modem_ops.o \
t7xx_cldma.o \
t7xx_hif_cldma.o \
t7xx_port_proxy.o \
......@@ -46,6 +46,7 @@
#include "t7xx_mhccif.h"
#include "t7xx_pci.h"
#include "t7xx_pcie_mac.h"
#include "t7xx_port_proxy.h"
#include "t7xx_reg.h"
#include "t7xx_state_monitor.h"
......@@ -55,7 +56,7 @@
#define CHECK_Q_STOP_TIMEOUT_US 1000000
#define CHECK_Q_STOP_STEP_US 10000
#define CLDMA_JUMBO_BUFF_SZ 64528 /* 63kB + CCCI header */
#define CLDMA_JUMBO_BUFF_SZ (63 * 1024 + sizeof(struct ccci_header))
static void md_cd_queue_struct_reset(struct cldma_queue *queue, struct cldma_ctrl *md_ctrl,
enum mtk_txrx tx_rx, unsigned int index)
......
......@@ -34,6 +34,8 @@
#include "t7xx_modem_ops.h"
#include "t7xx_pci.h"
#include "t7xx_pcie_mac.h"
#include "t7xx_port.h"
#include "t7xx_port_proxy.h"
#include "t7xx_reg.h"
#include "t7xx_state_monitor.h"
......@@ -273,6 +275,7 @@ static void t7xx_md_exception(struct t7xx_modem *md, enum hif_ex_stage stage)
if (stage == HIF_EX_CLEARQ_DONE) {
/* Give DHL time to flush data */
msleep(PORT_RESET_DELAY_MS);
t7xx_port_proxy_reset(md->port_prox);
}
t7xx_cldma_exception(md->md_ctrl[CLDMA_ID_MD], stage);
......@@ -426,6 +429,7 @@ int t7xx_md_reset(struct t7xx_pci_dev *t7xx_dev)
md->exp_id = 0;
t7xx_fsm_reset(md);
t7xx_cldma_reset(md->md_ctrl[CLDMA_ID_MD]);
t7xx_port_proxy_reset(md->port_prox);
md->md_init_finish = true;
return 0;
}
......@@ -462,14 +466,21 @@ int t7xx_md_init(struct t7xx_pci_dev *t7xx_dev)
if (ret)
goto err_uninit_fsm;
ret = t7xx_port_proxy_init(md);
if (ret)
goto err_uninit_md_cldma;
ret = t7xx_fsm_append_cmd(md->fsm_ctl, FSM_CMD_START, 0);
if (ret) /* fsm_uninit flushes cmd queue */
goto err_uninit_md_cldma;
goto err_uninit_proxy;
t7xx_md_sys_sw_init(t7xx_dev);
md->md_init_finish = true;
return 0;
err_uninit_proxy:
t7xx_port_proxy_uninit(md->port_prox);
err_uninit_md_cldma:
t7xx_cldma_exit(md->md_ctrl[CLDMA_ID_MD]);
......@@ -492,6 +503,7 @@ void t7xx_md_exit(struct t7xx_pci_dev *t7xx_dev)
return;
t7xx_fsm_append_cmd(md->fsm_ctl, FSM_CMD_PRE_STOP, FSM_CMD_FLAG_WAIT_FOR_COMPLETION);
t7xx_port_proxy_uninit(md->port_prox);
t7xx_cldma_exit(md->md_ctrl[CLDMA_ID_MD]);
t7xx_fsm_uninit(md);
destroy_workqueue(md->handshake_wq);
......
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2021, MediaTek Inc.
* Copyright (c) 2021-2022, Intel Corporation.
*
* Authors:
* Haijun Liu <haijun.liu@mediatek.com>
* Moises Veleta <moises.veleta@intel.com>
* Ricardo Martinez <ricardo.martinez@linux.intel.com>
*
* Contributors:
* Amir Hanania <amir.hanania@intel.com>
* Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* Chandrashekar Devegowda <chandrashekar.devegowda@intel.com>
* Eliot Lee <eliot.lee@intel.com>
*/
#ifndef __T7XX_PORT_H__
#define __T7XX_PORT_H__
#include <linux/bits.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/wwan.h>
#include "t7xx_hif_cldma.h"
#include "t7xx_pci.h"
#define PORT_CH_ID_MASK GENMASK(7, 0)
/* Channel ID and Message ID definitions.
* The channel number consists of peer_id(15:12) , channel_id(11:0)
* peer_id:
* 0:reserved, 1: to sAP, 2: to MD
*/
enum port_ch {
/* to MD */
PORT_CH_CONTROL_RX = 0x2000,
PORT_CH_CONTROL_TX = 0x2001,
PORT_CH_UART1_RX = 0x2006, /* META */
PORT_CH_UART1_TX = 0x2008,
PORT_CH_UART2_RX = 0x200a, /* AT */
PORT_CH_UART2_TX = 0x200c,
PORT_CH_MD_LOG_RX = 0x202a, /* MD logging */
PORT_CH_MD_LOG_TX = 0x202b,
PORT_CH_LB_IT_RX = 0x203e, /* Loop back test */
PORT_CH_LB_IT_TX = 0x203f,
PORT_CH_STATUS_RX = 0x2043, /* Status events */
PORT_CH_MIPC_RX = 0x20ce, /* MIPC */
PORT_CH_MIPC_TX = 0x20cf,
PORT_CH_MBIM_RX = 0x20d0,
PORT_CH_MBIM_TX = 0x20d1,
PORT_CH_DSS0_RX = 0x20d2,
PORT_CH_DSS0_TX = 0x20d3,
PORT_CH_DSS1_RX = 0x20d4,
PORT_CH_DSS1_TX = 0x20d5,
PORT_CH_DSS2_RX = 0x20d6,
PORT_CH_DSS2_TX = 0x20d7,
PORT_CH_DSS3_RX = 0x20d8,
PORT_CH_DSS3_TX = 0x20d9,
PORT_CH_DSS4_RX = 0x20da,
PORT_CH_DSS4_TX = 0x20db,
PORT_CH_DSS5_RX = 0x20dc,
PORT_CH_DSS5_TX = 0x20dd,
PORT_CH_DSS6_RX = 0x20de,
PORT_CH_DSS6_TX = 0x20df,
PORT_CH_DSS7_RX = 0x20e0,
PORT_CH_DSS7_TX = 0x20e1,
};
struct t7xx_port;
struct port_ops {
int (*init)(struct t7xx_port *port);
int (*recv_skb)(struct t7xx_port *port, struct sk_buff *skb);
void (*md_state_notify)(struct t7xx_port *port, unsigned int md_state);
void (*uninit)(struct t7xx_port *port);
int (*enable_chl)(struct t7xx_port *port);
int (*disable_chl)(struct t7xx_port *port);
};
struct t7xx_port_conf {
enum port_ch tx_ch;
enum port_ch rx_ch;
unsigned char txq_index;
unsigned char rxq_index;
unsigned char txq_exp_index;
unsigned char rxq_exp_index;
enum cldma_id path_id;
struct port_ops *ops;
char *name;
enum wwan_port_type port_type;
};
struct t7xx_port {
/* Members not initialized in definition */
const struct t7xx_port_conf *port_conf;
struct wwan_port *wwan_port;
struct t7xx_pci_dev *t7xx_dev;
struct device *dev;
u16 seq_nums[2]; /* TX/RX sequence numbers */
atomic_t usage_cnt;
struct list_head entry;
struct list_head queue_entry;
/* TX and RX flows are asymmetric since ports are multiplexed on
* queues.
*
* TX: data blocks are sent directly to a queue. Each port
* does not maintain a TX list; instead, they only provide
* a wait_queue_head for blocking writes.
*
* RX: Each port uses a RX list to hold packets,
* allowing the modem to dispatch RX packet as quickly as possible.
*/
struct sk_buff_head rx_skb_list;
spinlock_t port_update_lock; /* Protects port configuration */
wait_queue_head_t rx_wq;
int rx_length_th;
bool chan_enable;
struct task_struct *thread;
};
struct sk_buff *t7xx_port_alloc_skb(int payload);
int t7xx_port_enqueue_skb(struct t7xx_port *port, struct sk_buff *skb);
int t7xx_port_send_skb(struct t7xx_port *port, struct sk_buff *skb, unsigned int pkt_header,
unsigned int ex_msg);
#endif /* __T7XX_PORT_H__ */
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2021, MediaTek Inc.
* Copyright (c) 2021-2022, Intel Corporation.
*
* Authors:
* Amir Hanania <amir.hanania@intel.com>
* Haijun Liu <haijun.liu@mediatek.com>
* Moises Veleta <moises.veleta@intel.com>
* Ricardo Martinez <ricardo.martinez@linux.intel.com>
*
* Contributors:
* Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
* Eliot Lee <eliot.lee@intel.com>
* Sreehari Kancharla <sreehari.kancharla@intel.com>
*/
#ifndef __T7XX_PORT_PROXY_H__
#define __T7XX_PORT_PROXY_H__
#include <linux/bits.h>
#include <linux/device.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include "t7xx_hif_cldma.h"
#include "t7xx_modem_ops.h"
#include "t7xx_port.h"
#define MTK_QUEUES 16
#define RX_QUEUE_MAXLEN 32
#define CTRL_QUEUE_MAXLEN 16
struct port_proxy {
int port_count;
struct list_head rx_ch_ports[PORT_CH_ID_MASK + 1];
struct list_head queue_ports[CLDMA_NUM][MTK_QUEUES];
struct device *dev;
struct t7xx_port ports[];
};
struct ccci_header {
__le32 packet_header;
__le32 packet_len;
__le32 status;
__le32 ex_msg;
};
/* Coupled with HW - indicates if there is data following the CCCI header or not */
#define CCCI_HEADER_NO_DATA 0xffffffff
#define CCCI_H_AST_BIT BIT(31)
#define CCCI_H_SEQ_FLD GENMASK(30, 16)
#define CCCI_H_CHN_FLD GENMASK(15, 0)
#define PORT_INFO_RSRVD GENMASK(31, 16)
#define PORT_INFO_ENFLG BIT(15)
#define PORT_INFO_CH_ID GENMASK(14, 0)
#define PORT_ENUM_VER 0
#define PORT_ENUM_HEAD_PATTERN 0x5a5a5a5a
#define PORT_ENUM_TAIL_PATTERN 0xa5a5a5a5
#define PORT_ENUM_VER_MISMATCH 0x00657272
void t7xx_port_proxy_reset(struct port_proxy *port_prox);
void t7xx_port_proxy_uninit(struct port_proxy *port_prox);
int t7xx_port_proxy_init(struct t7xx_modem *md);
void t7xx_port_proxy_md_status_notify(struct port_proxy *port_prox, unsigned int state);
int t7xx_port_proxy_chl_enable_disable(struct port_proxy *port_prox, unsigned int ch_id,
bool en_flag);
#endif /* __T7XX_PORT_PROXY_H__ */
......@@ -37,6 +37,7 @@
#include "t7xx_modem_ops.h"
#include "t7xx_pci.h"
#include "t7xx_pcie_mac.h"
#include "t7xx_port_proxy.h"
#include "t7xx_reg.h"
#include "t7xx_state_monitor.h"
......@@ -90,6 +91,9 @@ static void fsm_state_notify(struct t7xx_modem *md, enum md_state state)
void t7xx_fsm_broadcast_state(struct t7xx_fsm_ctl *ctl, enum md_state state)
{
ctl->md_state = state;
/* Update to port first, otherwise sending message on HS2 may fail */
t7xx_port_proxy_md_status_notify(ctl->md->port_prox, state);
fsm_state_notify(ctl->md, state);
}
......@@ -258,6 +262,7 @@ static void t7xx_fsm_broadcast_ready_state(struct t7xx_fsm_ctl *ctl)
ctl->md_state = MD_STATE_READY;
fsm_state_notify(ctl->md, MD_STATE_READY);
t7xx_port_proxy_md_status_notify(ctl->md->port_prox, MD_STATE_READY);
}
static void fsm_routine_ready(struct t7xx_fsm_ctl *ctl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment