[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b610e64-9013-5c8c-93e9-95994d79f128@gmail.com>
Date: Mon, 29 Nov 2021 21:46:55 +0100
From: Heiner Kallweit <hkallweit1@...il.com>
To: Hayes Wang <hayeswang@...ltek.com>,
Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>
Cc: netdev@...r.kernel.org, nic_swsd@...ltek.com
Subject: Re: [RFC PATCH 3/4] r8169: support CMAC
On 29.11.2021 11:13, Hayes Wang wrote:
> Support CMAC for RTL8111EP and RTL8111FP.
>
> CMAC is the major interface to configure the firmware when dash is
> enabled.
>
> Signed-off-by: Hayes Wang <hayeswang@...ltek.com>
> ---
> drivers/net/ethernet/realtek/Makefile | 2 +-
> drivers/net/ethernet/realtek/r8169.h | 2 +
> drivers/net/ethernet/realtek/r8169_dash.c | 756 ++++++++++++++++++++++
> drivers/net/ethernet/realtek/r8169_dash.h | 22 +
> drivers/net/ethernet/realtek/r8169_main.c | 54 +-
> 5 files changed, 824 insertions(+), 12 deletions(-)
> create mode 100644 drivers/net/ethernet/realtek/r8169_dash.c
> create mode 100644 drivers/net/ethernet/realtek/r8169_dash.h
>
> diff --git a/drivers/net/ethernet/realtek/Makefile b/drivers/net/ethernet/realtek/Makefile
> index 2e1d78b106b0..8f3372ee92ff 100644
> --- a/drivers/net/ethernet/realtek/Makefile
> +++ b/drivers/net/ethernet/realtek/Makefile
> @@ -6,5 +6,5 @@
> obj-$(CONFIG_8139CP) += 8139cp.o
> obj-$(CONFIG_8139TOO) += 8139too.o
> obj-$(CONFIG_ATP) += atp.o
> -r8169-objs += r8169_main.o r8169_firmware.o r8169_phy_config.o
> +r8169-objs += r8169_main.o r8169_firmware.o r8169_phy_config.o r8169_dash.o
> obj-$(CONFIG_R8169) += r8169.o
> diff --git a/drivers/net/ethernet/realtek/r8169.h b/drivers/net/ethernet/realtek/r8169.h
> index 7db647b4796f..b75484a2a580 100644
> --- a/drivers/net/ethernet/realtek/r8169.h
> +++ b/drivers/net/ethernet/realtek/r8169.h
> @@ -78,5 +78,7 @@ u8 rtl8168d_efuse_read(struct rtl8169_private *tp, int reg_addr);
> void r8169_hw_phy_config(struct rtl8169_private *tp, struct phy_device *phydev,
> enum mac_version ver);
>
> +u32 r8168ep_ocp_read(struct rtl8169_private *tp, u16 reg);
> u32 r8168_type2_read(struct rtl8169_private *tp, u32 addr);
> +void r8168ep_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data);
> void r8168_type2_write(struct rtl8169_private *tp, u8 mask, u32 addr, u32 val);
> diff --git a/drivers/net/ethernet/realtek/r8169_dash.c b/drivers/net/ethernet/realtek/r8169_dash.c
> new file mode 100644
> index 000000000000..acee7519e9f1
> --- /dev/null
> +++ b/drivers/net/ethernet/realtek/r8169_dash.c
> @@ -0,0 +1,756 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/pci.h>
> +#include <linux/workqueue.h>
> +#include <linux/rtnetlink.h>
> +#include <linux/string.h>
> +#include "r8169.h"
> +#include "r8169_dash.h"
> +
> +#define IBCR0 0xf8
> +#define IBCR2 0xf9
> +#define IBIMR0 0xfa
> +#define IBISR0 0xfb
> +
> +#define RTXS_LS BIT(12)
> +#define RTXS_FS BIT(13)
> +#define RTXS_EOR BIT(14)
> +#define RTXS_OWN BIT(15)
> +
> +#define DASH_ISR_ROK BIT(0)
> +#define DASH_ISR_RDU BIT(1)
> +#define DASH_ISR_TOK BIT(2)
> +#define DASH_ISR_TDU BIT(3)
> +#define DASH_ISR_TX_DISABLE_IDLE BIT(5)
> +#define DASH_ISR_RX_DISABLE_IDLE BIT(6)
> +
> +#define CMAC_DESC_NUM 4
> +#define CMAC_DESC_SIZE (CMAC_DESC_NUM * sizeof(struct cmac_desc))
> +#define CMAC_TIMEOUT (HZ * 5)
> +
> +#define OOB_CMD_DRIVER_START 0x05
> +#define OOB_CMD_DRIVER_STOP 0x06
> +#define OOB_CMD_CMAC_STOP 0x25
> +#define OOB_CMD_CMAC_INIT 0x26
> +#define OOB_CMD_CMAC_RESET 0x2a
> +
> +enum dash_cmac_state {
> + CMAC_STATE_STOP = 0,
> + CMAC_STATE_READY,
> + CMAC_STATE_RUNNING,
> +};
> +
> +enum dash_flag {
> + DASH_FLAG_CHECK_CMAC = 0,
> + DASH_FLAG_MAX
> +};
> +
> +#pragma pack(push)
> +#pragma pack(1)
> +
> +struct cmac_desc {
> + __le16 length;
> + __le16 status;
> + __le32 resv;
> + __le64 dma_addr;
> +};
> +
> +struct oob_hdr {
> + __le32 len;
> + u8 type;
> + u8 flag;
> + u8 host_req;
> + u8 res;
> +};
> +
> +#pragma pack(pop)
> +
> +struct dash_tx_info {
> + u8 *buf;
> + u32 len;
> + bool ack;
> +};
> +
> +struct rtl_dash {
> + struct rtl8169_private *tp;
> + struct pci_dev *pdev_cmac;
> + void __iomem *cmac_ioaddr;
> + struct cmac_desc *tx_desc, *rx_desc;
> + struct page *tx_buf, *rx_buf;
> + struct dash_tx_info tx_info[CMAC_DESC_NUM];
> + struct tasklet_struct tl;
Please see the following in include/linux/interrupt.h:
/* Tasklets --- multithreaded analogue of BHs.
This API is deprecated. Please consider using threaded IRQs instead:
https://lore.kernel.org/lkml/20200716081538.2sivhkj4hcyrusem@linutronix.de
Powered by blists - more mailing lists