// SPDX-License-Identifier: GPL-2.0-only
/*
################################################################################
#
# r8168 is the Linux device driver released for Realtek Gigabit Ethernet
# controllers with PCI-Express interface.
#
# Copyright(c) 2021 Realtek Semiconductor Corp. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.
#
# Author:
# Realtek NIC software team <nicfae@realtek.com>
# No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
#
################################################################################
*/
/************************************************************************************
* This product is covered by one or more of the following patents:
* US6,570,884, US6,115,776, and US6,327,625.
***********************************************************************************/
/*
* This driver is modified from r8169.c in Linux kernel 2.6.18
*/
/* In Linux 5.4 asm_inline was introduced, but it's not supported by clang.
* Redefine it to just asm to enable successful compilation.
*/
#include <linux/module.h>
#include <linux/version.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/mii.h>
#include <linux/if_vlan.h>
#include <linux/crc32.h>
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/ip.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
#include <linux/ipv6.h>
#include <net/ip6_checksum.h>
#endif
#include <linux/tcp.h>
#include <linux/init.h>
#include <linux/rtnetlink.h>
#include <linux/completion.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
#include <linux/pci-aspm.h>
#endif
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,37)
#include <linux/prefetch.h>
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#define dev_printk(A,B,fmt,args...) printk(A fmt,##args)
#else
#include <linux/dma-mapping.h>
#include <linux/moduleparam.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
#include <linux/mdio.h>
#endif
#include <asm/io.h>
#include <asm/irq.h>
#include "r8168.h"
#include "r8168_asf.h"
#include "rtl_eeprom.h"
#include "rtltool.h"
#include "r8168_firmware.h"
#ifdef ENABLE_R8168_PROCFS
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#endif
#define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw"
#define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw"
#define FIRMWARE_8168E_1 "rtl_nic/rtl8168e-1.fw"
#define FIRMWARE_8168E_2 "rtl_nic/rtl8168e-2.fw"
#define FIRMWARE_8168E_3 "rtl_nic/rtl8168e-3.fw"
#define FIRMWARE_8168E_4 "rtl_nic/rtl8168e-4.fw"
#define FIRMWARE_8168F_1 "rtl_nic/rtl8168f-1.fw"
#define FIRMWARE_8168F_2 "rtl_nic/rtl8168f-2.fw"
#define FIRMWARE_8411_1 "rtl_nic/rtl8411-1.fw"
#define FIRMWARE_8411_2 "rtl_nic/rtl8411-2.fw"
#define FIRMWARE_8168G_2 "rtl_nic/rtl8168g-2.fw"
#define FIRMWARE_8168G_3 "rtl_nic/rtl8168g-3.fw"
#define FIRMWARE_8168EP_1 "rtl_nic/rtl8168ep-1.fw"
#define FIRMWARE_8168EP_2 "rtl_nic/rtl8168ep-2.fw"
#define FIRMWARE_8168EP_3 "rtl_nic/rtl8168ep-3.fw"
#define FIRMWARE_8168H_1 "rtl_nic/rtl8168h-1.fw"
#define FIRMWARE_8168H_2 "rtl_nic/rtl8168h-2.fw"
#define FIRMWARE_8168FP_3 "rtl_nic/rtl8168fp-3.fw"
#define FIRMWARE_8168FP_4 "rtl_nic/rtl8168fp-4.fw"
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
The RTL chips use a 64 element hash table based on the Ethernet CRC. */
static const int multicast_filter_limit = 32;
static const struct {
const char *name;
const char *fw_name;
} rtl_chip_fw_infos[] = {
/* PCI-E devices. */
[CFG_METHOD_1] = {"RTL8168B/8111", },
[CFG_METHOD_2] = {"RTL8168B/8111", },
[CFG_METHOD_3] = {"RTL8168B/8111", },
[CFG_METHOD_4] = {"RTL8168C/8111C", },
[CFG_METHOD_5] = {"RTL8168C/8111C", },
[CFG_METHOD_6] = {"RTL8168C/8111C", },
[CFG_METHOD_7] = {"RTL8168CP/8111CP", },
[CFG_METHOD_8] = {"RTL8168CP/8111CP", },
[CFG_METHOD_9] = {"RTL8168D/8111D", FIRMWARE_8168D_1},
[CFG_METHOD_10] = {"RTL8168D/8111D", FIRMWARE_8168D_2},
[CFG_METHOD_11] = {"RTL8168DP/8111DP", },
[CFG_METHOD_12] = {"RTL8168DP/8111DP", },
[CFG_METHOD_13] = {"RTL8168DP/8111DP", },
[CFG_METHOD_14] = {"RTL8168E/8111E", FIRMWARE_8168E_1},
[CFG_METHOD_15] = {"RTL8168E/8111E", FIRMWARE_8168E_2},
[CFG_METHOD_16] = {"RTL8168E-VL/8111E-VL", FIRMWARE_8168E_3},
[CFG_METHOD_17] = {"RTL8168E-VL/8111E-VL", FIRMWARE_8168E_4},
[CFG_METHOD_18] = {"RTL8168F/8111F", FIRMWARE_8168F_1},
[CFG_METHOD_19] = {"RTL8168F/8111F", FIRMWARE_8168F_2},
[CFG_METHOD_20] = {"RTL8411", FIRMWARE_8411_1},
[CFG_METHOD_21] = {"RTL8168G/8111G", FIRMWARE_8168G_2},
[CFG_METHOD_22] = {"RTL8168G/8111G", },
[CFG_METHOD_23] = {"RTL8168EP/8111EP", FIRMWARE_8168EP_1},
[CFG_METHOD_24] = {"RTL8168GU/8111GU", },
[CFG_METHOD_25] = {"RTL8168GU/8111GU", FIRMWARE_8168G_3},
[CFG_METHOD_26] = {"8411B", FIRMWARE_8411_2},
[CFG_METHOD_27] = {"RTL8168EP/8111EP", FIRMWARE_8168EP_2},
[CFG_METHOD_28] = {"RTL8168EP/8111EP", FIRMWARE_8168EP_3},
[CFG_METHOD_29] = {"RTL8168H/8111H", FIRMWARE_8168H_1},
[CFG_METHOD_30] = {"RTL8168H/8111H", FIRMWARE_8168H_2},
[CFG_METHOD_31] = {"RTL8168FP/8111FP", },
[CFG_METHOD_32] = {"RTL8168FP/8111FP", FIRMWARE_8168FP_3},
[CFG_METHOD_33] = {"RTL8168FP/8111FP", FIRMWARE_8168FP_4},
[CFG_METHOD_DEFAULT] = {"Unknown", },
};
#define _R(NAME,MAC,RCR,MASK, JumFrameSz) \
{ .name = NAME, .mcfg = MAC, .RCR_Cfg = RCR, .RxConfigMask = MASK, .jumbo_frame_sz = JumFrameSz }
static const struct {
const char *name;
u8 mcfg;
u32 RCR_Cfg;
u32 RxConfigMask; /* Clears the bits supported by this chip */
u32 jumbo_frame_sz;
} rtl_chip_info[] = {
_R("RTL8168B/8111B",
CFG_METHOD_1,
(Reserved2_data << Reserved2_shift) | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
Jumbo_Frame_4k),
_R("RTL8168B/8111B",
CFG_METHOD_2,
(Reserved2_data << Reserved2_shift) | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
Jumbo_Frame_4k),
_R("RTL8168B/8111B",
CFG_METHOD_3,
(Reserved2_data << Reserved2_shift) | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
Jumbo_Frame_4k),
_R("RTL8168C/8111C",
CFG_METHOD_4,
RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
Jumbo_Frame_6k),
_R("RTL8168C/8111C",
CFG_METHOD_5,
RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
Jumbo_Frame_6k),
_R("RTL8168C/8111C",
CFG_METHOD_6,
RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
Jumbo_Frame_6k),
_R("RTL8168CP/8111CP",
CFG_METHOD_7,
RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
0xff7e1880,
没有合适的资源?快使用搜索试试~ 我知道了~
RTL8168;TL8111/8168/8411 PCI Express Gigabit Ethernet Controller
共18个文件
h:8个
c:5个
makefile:2个
5星 · 超过95%的资源 需积分: 1 23 下载量 136 浏览量
2022-04-11
18:44:53
上传
评论
收藏 156KB ZIP 举报
温馨提示
RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller的ubuntu18驱动
资源详情
资源评论
资源推荐
收起资源包目录
r8168-master.zip (18个子文件)
r8168-master
src
r8168_n.c 1.14MB
r8168_asf.c 16KB
r8168.h 57KB
rtl_eeprom.c 8KB
r8168_fiber.h 2KB
r8168_dash.h 7KB
rtltool.h 2KB
r8168_firmware.c 9KB
rtltool.c 12KB
r8168_realwow.h 4KB
Makefile_linux24x 2KB
rtl_eeprom.h 2KB
Makefile 5KB
r8168_asf.h 9KB
r8168_firmware.h 2KB
README 4KB
Makefile 2KB
autorun.sh 2KB
共 18 条
- 1
Tim375
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5