Update saibcm-modules to compile with 5.10 kernel

Update the build rules in saibcm-modules to use the 5.10 kernel instead
of searching for the 4.19 kernel. In addition, some code changes were
done to get it to compile. The main categories of such changes are as
follows:

* For /proc files, `struct file_operations` has been replaced with
`struct proc_ops`.
* Y2038 changes to use the new APIs, since `do_gettimeofday()` is no
longer available.
* Minor changes in how external kernel module symbols are read by
modpost.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This commit is contained in:
Saikrishna Arcot 2021-07-08 17:30:01 -07:00 committed by Saikrishna Arcot
parent 20598f3019
commit 4f9569132f
28 changed files with 293 additions and 116 deletions

@ -1 +1 @@
Subproject commit f40eb1bd30d048bb3ba2827285783869b3c4266d
Subproject commit be53f7910a9e8b37bf191527a6da3aba0414d4b8

View File

@ -10,5 +10,5 @@ Standards-Version: 3.9.3
Package: opennsl-modules
Architecture: amd64
Section: main
Depends: linux-image-4.19.0-12-2-amd64-unsigned
Depends: linux-image-5.10.0-8-2-amd64-unsigned
Description: kernel modules for broadcom SAI

View File

@ -1 +1 @@
lib/modules/4.19.0-12-2-amd64/extra
lib/modules/5.10.0-8-2-amd64/extra

View File

@ -1,8 +1,8 @@
systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/4.19.0-12-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/4.19.0-12-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/4.19.0-12-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/4.19.0-12-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/psample.ko lib/modules/4.19.0-12-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/4.19.0-12-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/5.10.0-8-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/5.10.0-8-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/5.10.0-8-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/5.10.0-8-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/psample.ko lib/modules/5.10.0-8-2-amd64/extra
systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/5.10.0-8-2-amd64/extra
systemd/opennsl-modules.service lib/systemd/system
sdklt/linux/bde/linux_ngbde.ko lib/modules/4.19.0-12-2-amd64/extra
sdklt/linux/bde/linux_ngbde.ko lib/modules/5.10.0-8-2-amd64/extra

View File

@ -34,8 +34,8 @@ sname:=opennsl
PACKAGE=opennsl-modules
# modifieable for experiments or debugging m-a
MA_DIR ?= /usr/share/modass
KVERSION ?= 4.19.0-12-2-amd64
KERNVERSION ?= 4.19.0-12-2
KVERSION ?= 5.10.0-8-2-amd64
KERNVERSION ?= 5.10.0-8-2
# load generic variable handling
-include $(MA_DIR)/include/generic.make
@ -94,6 +94,7 @@ build-arch-stamp:
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/ /lib/modules/$(KERNVERSION)-amd64/build
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/include/generated/ /usr/src/linux-headers-$(KERNVERSION)-common/include/generated
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/arch/x86/include/generated/ /usr/src/linux-headers-$(KERNVERSION)-common/arch/x86/include/generated
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/arch/x86/module.lds /usr/src/linux-headers-$(KERNVERSION)-common/arch/x86/module.lds
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/include/config/ /usr/src/linux-headers-$(KERNVERSION)-common/include/config
cd /; sudo cp /usr/src/linux-headers-$(KERNVERSION)-amd64/Module.symvers /usr/src/linux-headers-$(KERNVERSION)-common/Module.symvers

View File

@ -36,7 +36,7 @@ ngbde_iio_map(void *devh, phys_addr_t addr, phys_addr_t size)
ngbde_iio_unmap(devh);
}
sd->iio_mem = ioremap_nocache(addr, size);
sd->iio_mem = ioremap(addr, size);
if (sd->iio_mem) {
/* Save mapped resources */

View File

@ -65,7 +65,7 @@ iproc_cmicd_probe(struct platform_device *pldev)
(void *)memres->start, (void *)memres->end);
}
base_address = ioremap_nocache(memres->start, size);
base_address = ioremap(memres->start, size);
if (!base_address) {
printk(KERN_WARNING "Error mapping iProc CMIC registers");
return -1;

View File

@ -36,7 +36,7 @@ ngbde_paxb_map(void *devh, phys_addr_t addr, phys_addr_t size)
iounmap(sd->paxb_mem);
}
sd->paxb_mem = ioremap_nocache(addr, size);
sd->paxb_mem = ioremap(addr, size);
if (sd->paxb_mem) {
/* Save mapped resources */

View File

@ -36,7 +36,7 @@ ngbde_pio_map(void *devh, phys_addr_t addr, phys_addr_t size)
ngbde_pio_unmap(devh);
}
sd->pio_mem = ioremap_nocache(addr, size);
sd->pio_mem = ioremap(addr, size);
if (sd->pio_mem) {
/* Save mapped resources */

View File

@ -88,6 +88,7 @@ proc_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_fops = {
owner: THIS_MODULE,
open: proc_open,
@ -95,6 +96,14 @@ static struct file_operations proc_fops = {
llseek: seq_lseek,
release: proc_release,
};
#else
static struct proc_ops proc_fops = {
proc_open: proc_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_release,
};
#endif
int
ngbde_procfs_init(void)

View File

@ -39,11 +39,19 @@
unsigned long
sal_time_usecs(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct timeval tv;
kal_time_val_get(&tv);
return tv.tv_sec * 1000000 + tv.tv_usec;
#else
struct timespec64 tv;
kal_time_val_get(&tv);
return tv.tv_sec * 1000000 + tv.tv_nsec / 1000;
#endif
}
void

View File

@ -113,7 +113,7 @@ kal_time_val_get(struct timeval *tv)
{
do_gettimeofday(tv);
}
#else
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static inline void
kal_time_val_get(struct timeval *tv)
{
@ -122,6 +122,12 @@ kal_time_val_get(struct timeval *tv)
tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / 1000;
}
#else
static inline void
kal_time_val_get(struct timespec64 *tv)
{
ktime_get_real_ts64(tv);
}
#endif /* KERNEL_VERSION(3,17,0) */
static inline unsigned long

View File

@ -233,7 +233,11 @@ ngknet_pkt_dump(uint8_t *data, int len)
static void
ngknet_pkt_stats(struct pdma_dev *pdev, int dir)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct timeval tv0[2], tv1[2];
#else
static struct timespec64 tv0[2], tv1[2];
#endif
static uint32_t pkts[2] = {0}, prts[2] = {0};
static uint64_t intrs = 0;
uint32_t iv_time;
@ -257,8 +261,13 @@ ngknet_pkt_stats(struct pdma_dev *pdev, int dir)
}
if (++pkts[dir] >= boudary) {
kal_time_val_get(&tv1[dir]);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
iv_time = (tv1[dir].tv_sec - tv0[dir].tv_sec) * 1000000 +
(tv1[dir].tv_usec - tv0[dir].tv_usec);
#else
iv_time = (tv1[dir].tv_sec - tv0[dir].tv_sec) * 1000000 +
(tv1[dir].tv_nsec - tv0[dir].tv_nsec) / 1000;
#endif
pps = boudary * 1000 / (iv_time / 1000);
prts[dir]++;
/* pdev->stats.intrs is reset and re-count from 0. */

View File

@ -88,6 +88,7 @@ proc_debug_level_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_debug_level_fops = {
owner: THIS_MODULE,
open: proc_debug_level_open,
@ -96,6 +97,15 @@ static struct file_operations proc_debug_level_fops = {
llseek: seq_lseek,
release: proc_debug_level_release,
};
#else
static struct proc_ops proc_debug_level_fops = {
proc_open: proc_debug_level_open,
proc_read: seq_read,
proc_write: proc_debug_level_write,
proc_lseek: seq_lseek,
proc_release: proc_debug_level_release,
};
#endif
static int
proc_device_info_show(struct seq_file *m, void *v)
@ -168,6 +178,7 @@ proc_device_info_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_device_info_fops = {
owner: THIS_MODULE,
open: proc_device_info_open,
@ -175,6 +186,14 @@ static struct file_operations proc_device_info_fops = {
llseek: seq_lseek,
release: proc_device_info_release,
};
#else
static struct proc_ops proc_device_info_fops = {
proc_open: proc_device_info_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_device_info_release,
};
#endif
static int
proc_filter_info_show(struct seq_file *m, void *v)
@ -250,6 +269,7 @@ proc_filter_info_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_filter_info_fops = {
owner: THIS_MODULE,
open: proc_filter_info_open,
@ -257,6 +277,14 @@ static struct file_operations proc_filter_info_fops = {
llseek: seq_lseek,
release: proc_filter_info_release,
};
#else
static struct proc_ops proc_filter_info_fops = {
proc_open: proc_filter_info_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_filter_info_release,
};
#endif
static int
proc_netif_info_show(struct seq_file *m, void *v)
@ -342,6 +370,7 @@ proc_netif_info_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_netif_info_fops = {
owner: THIS_MODULE,
open: proc_netif_info_open,
@ -349,6 +378,14 @@ static struct file_operations proc_netif_info_fops = {
llseek: seq_lseek,
release: proc_netif_info_release,
};
#else
static struct proc_ops proc_netif_info_fops = {
proc_open: proc_netif_info_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_netif_info_release,
};
#endif
static int
proc_pkt_stats_show(struct seq_file *m, void *v)
@ -418,6 +455,7 @@ proc_pkt_stats_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_pkt_stats_fops = {
owner: THIS_MODULE,
open: proc_pkt_stats_open,
@ -425,6 +463,14 @@ static struct file_operations proc_pkt_stats_fops = {
llseek: seq_lseek,
release: proc_pkt_stats_release,
};
#else
static struct proc_ops proc_pkt_stats_fops = {
proc_open: proc_pkt_stats_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_pkt_stats_release,
};
#endif
static int
proc_rate_limit_show(struct seq_file *m, void *v)
@ -464,6 +510,7 @@ proc_rate_limit_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_rate_limit_fops = {
owner: THIS_MODULE,
open: proc_rate_limit_open,
@ -472,6 +519,15 @@ static struct file_operations proc_rate_limit_fops = {
llseek: seq_lseek,
release: proc_rate_limit_release,
};
#else
static struct proc_ops proc_rate_limit_fops = {
proc_open: proc_rate_limit_open,
proc_read: seq_read,
proc_write: proc_rate_limit_write,
proc_lseek: seq_lseek,
proc_release: proc_rate_limit_release,
};
#endif
static int
proc_reg_status_show(struct seq_file *m, void *v)
@ -515,6 +571,7 @@ proc_reg_status_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_reg_status_fops = {
owner: THIS_MODULE,
open: proc_reg_status_open,
@ -522,6 +579,14 @@ static struct file_operations proc_reg_status_fops = {
llseek: seq_lseek,
release: proc_reg_status_release,
};
#else
static struct proc_ops proc_reg_status_fops = {
proc_open: proc_reg_status_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_reg_status_release,
};
#endif
static int
proc_ring_status_show(struct seq_file *m, void *v)
@ -569,6 +634,7 @@ proc_ring_status_release(struct inode *inode, struct file *file)
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations proc_ring_status_fops = {
owner: THIS_MODULE,
open: proc_ring_status_open,
@ -576,6 +642,14 @@ static struct file_operations proc_ring_status_fops = {
llseek: seq_lseek,
release: proc_ring_status_release,
};
#else
static struct proc_ops proc_ring_status_fops = {
proc_open: proc_ring_status_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_release: proc_ring_status_release,
};
#endif
int
ngknet_procfs_init(void)

View File

@ -398,6 +398,17 @@ static struct file_operations ngknetcb_fops = {
.mmap = ngknetcb_mmap,
};
static struct proc_ops ngknetcb_proc_ops = {
.proc_open = ngknetcb_open,
.proc_read = seq_read,
.proc_write = ngknetcb_write,
.proc_lseek = seq_lseek,
.proc_release = ngknetcb_release,
.proc_ioctl = ngknetcb_ioctl,
.proc_compat_ioctl = ngknetcb_ioctl,
.proc_mmap = ngknetcb_mmap,
};
static int __init
ngknetcb_init_module(void)
{
@ -411,7 +422,7 @@ ngknetcb_init_module(void)
return rv;
}
PROC_CREATE(entry, NGKNETCB_MODULE_NAME, 0666, NULL, &ngknetcb_fops);
PROC_CREATE(entry, NGKNETCB_MODULE_NAME, 0666, NULL, &ngknetcb_proc_ops);
if (entry == NULL) {
printk(KERN_ERR "%s: proc_mkdir failed\n",
NGKNETCB_MODULE_NAME);

View File

@ -628,13 +628,12 @@ psample_proc_rate_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_rate_file_ops = {
owner: THIS_MODULE,
open: psample_proc_rate_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_rate_write,
release: single_release,
struct proc_ops psample_proc_rate_file_ops = {
proc_open: psample_proc_rate_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_rate_write,
proc_release: single_release,
};
/*
@ -727,13 +726,12 @@ psample_proc_size_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_size_file_ops = {
owner: THIS_MODULE,
open: psample_proc_size_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_size_write,
release: single_release,
struct proc_ops psample_proc_size_file_ops = {
proc_open: psample_proc_size_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_size_write,
proc_release: single_release,
};
/*
@ -768,13 +766,12 @@ psample_proc_map_open(struct inode * inode, struct file * file)
return single_open(file, psample_proc_map_show, NULL);
}
struct file_operations psample_proc_map_file_ops = {
owner: THIS_MODULE,
open: psample_proc_map_open,
read: seq_read,
llseek: seq_lseek,
write: NULL,
release: single_release,
struct proc_ops psample_proc_map_file_ops = {
proc_open: psample_proc_map_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: NULL,
proc_release: single_release,
};
/*
@ -834,13 +831,12 @@ psample_proc_debug_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_debug_file_ops = {
owner: THIS_MODULE,
open: psample_proc_debug_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_debug_write,
release: single_release,
struct proc_ops psample_proc_debug_file_ops = {
proc_open: psample_proc_debug_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_debug_write,
proc_release: single_release,
};
static int
@ -896,13 +892,12 @@ psample_proc_stats_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_stats_file_ops = {
owner: THIS_MODULE,
open: psample_proc_stats_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_stats_write,
release: single_release,
struct proc_ops psample_proc_stats_file_ops = {
proc_open: psample_proc_stats_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_stats_write,
proc_release: single_release,
};
int psample_cleanup(void)

View File

@ -49,7 +49,7 @@
/* ioremap is broken in kernel */
#define IOREMAP(addr, size) ((void *)KSEG1ADDR(addr))
#else
#define IOREMAP(addr, size) ioremap_nocache(addr, size)
#define IOREMAP(addr, size) ioremap(addr, size)
#endif
#if defined (__mips__)

View File

@ -1274,7 +1274,8 @@ _sinval(int d, void *ptr, int length)
/* FIXME: need proper function to replace dma_cache_sync */
dma_sync_single_for_cpu(NULL, (unsigned long)ptr, length, DMA_BIDIRECTIONAL);
#else
dma_cache_sync(NULL, ptr, length, DMA_BIDIRECTIONAL);
// TODO: This needs to be verified
dma_sync_single_for_device(NULL, ptr, length, DMA_BIDIRECTIONAL);
#endif
#endif
return 0;
@ -1290,7 +1291,8 @@ _sflush(int d, void *ptr, int length)
/* FIXME: need proper function to replace dma_cache_sync */
dma_sync_single_for_cpu(NULL, (unsigned long)ptr, length, DMA_BIDIRECTIONAL);
#else
dma_cache_sync(NULL, ptr, length, DMA_BIDIRECTIONAL);
// TODO: This needs to be verified
dma_sync_single_for_device(NULL, ptr, length, DMA_BIDIRECTIONAL);
#endif
#endif

View File

@ -64,7 +64,7 @@ $(KMODULE): $(MODULE)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
kernel_libs:

View File

@ -117,7 +117,7 @@ be made.
#define HX5_INTC_INTR_STATUS_BASE (HX5_INTC_INTR_STATUS_REG0)
#define HX5_INTC_INTR_RAW_STATUS_BASE (HX5_INTC_INTR_RAW_STATUS_REG0)
#define IOREMAP(addr, size) ioremap_nocache(addr, size)
#define IOREMAP(addr, size) ioremap(addr, size)
#define HX5_IHOST_GICD_ISENABLERN_0 (0x10781100)
#define HX5_IHOST_GICD_ISENABLERN_1 (0x10781104)

View File

@ -59,7 +59,7 @@ $(KMODULE): $(MODULE)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
# Make.depend is before clean:: so that Make.depend's clean:: runs first.

View File

@ -6885,6 +6885,7 @@ bkn_proc_link_write(struct file *file, const char *buf,
return count;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct file_operations bkn_proc_link_file_ops = {
owner: THIS_MODULE,
open: bkn_proc_link_open,
@ -6893,6 +6894,15 @@ struct file_operations bkn_proc_link_file_ops = {
write: bkn_proc_link_write,
release: single_release,
};
#else
struct proc_ops bkn_proc_link_file_ops = {
proc_open: bkn_proc_link_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bkn_proc_link_write,
proc_release: single_release,
};
#endif
/*
* Device Rate Control Proc Read Entry
@ -6995,6 +7005,7 @@ bkn_proc_rate_write(struct file *file, const char *buf,
return count;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct file_operations bkn_proc_rate_file_ops = {
owner: THIS_MODULE,
open: bkn_proc_rate_open,
@ -7003,6 +7014,15 @@ struct file_operations bkn_proc_rate_file_ops = {
write: bkn_proc_rate_write,
release: single_release,
};
#else
struct proc_ops bkn_proc_rate_file_ops = {
proc_open: bkn_proc_rate_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bkn_proc_rate_write,
proc_release: single_release,
};
#endif
/*
* Driver DMA Proc Entry
@ -7245,6 +7265,7 @@ bkn_seq_dma_open(struct inode *inode, struct file *file)
return seq_open(file, &bkn_seq_dma_ops);
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
static struct file_operations bkn_seq_dma_file_ops = {
.owner = THIS_MODULE,
.open = bkn_seq_dma_open,
@ -7252,6 +7273,14 @@ static struct file_operations bkn_seq_dma_file_ops = {
.llseek = seq_lseek,
.release = seq_release
};
#else
static struct proc_ops bkn_seq_dma_file_ops = {
.proc_open = bkn_seq_dma_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = seq_release
};
#endif
/*
* Device Debug Control Proc Write Entry
@ -7382,6 +7411,7 @@ static int bkn_proc_debug_open(struct inode * inode, struct file * file)
return single_open(file, bkn_proc_debug_show, NULL);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct file_operations bkn_proc_debug_file_ops = {
owner: THIS_MODULE,
open: bkn_proc_debug_open,
@ -7390,6 +7420,15 @@ struct file_operations bkn_proc_debug_file_ops = {
write: bkn_proc_debug_write,
release: single_release,
};
#else
struct proc_ops bkn_proc_debug_file_ops = {
proc_open: bkn_proc_debug_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bkn_proc_debug_write,
proc_release: single_release,
};
#endif
/*
* Device Statistics Proc Entry
@ -7511,6 +7550,7 @@ bkn_proc_stats_write(struct file *file, const char *buf,
return count;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct file_operations bkn_proc_stats_file_ops = {
owner: THIS_MODULE,
open: bkn_proc_stats_open,
@ -7519,6 +7559,15 @@ struct file_operations bkn_proc_stats_file_ops = {
write: bkn_proc_stats_write,
release: single_release,
};
#else
struct proc_ops bkn_proc_stats_file_ops = {
proc_open: bkn_proc_stats_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bkn_proc_stats_write,
proc_release: single_release,
};
#endif
/*
@ -7688,6 +7737,7 @@ bkn_proc_dstats_write(struct file *file, const char *buf,
return count;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct file_operations bkn_proc_dstats_file_ops = {
owner: THIS_MODULE,
open: bkn_proc_dstats_open,
@ -7696,6 +7746,15 @@ struct file_operations bkn_proc_dstats_file_ops = {
write: bkn_proc_dstats_write,
release: single_release,
};
#else
struct proc_ops bkn_proc_dstats_file_ops = {
proc_open: bkn_proc_dstats_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bkn_proc_dstats_write,
proc_release: single_release,
};
#endif
/*
* PTP Statistics Proc Entry

View File

@ -36,7 +36,7 @@ KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
build: $(MODULE) $(KMODULE)
endif
#KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/kernel_module/Module.symvers
KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/kernel_module/Module.symvers
KBUILD_EXTRA_SYMBOLS += ${BLDDIR}/../bcm-knet/kernel_module/Module.symvers
# BCM PTP Clock Device
@ -49,7 +49,7 @@ $(KMODULE): $(MODULE)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
# Make.depend is before clean:: so that Make.depend's clean:: runs first.

View File

@ -1594,13 +1594,12 @@ bksync_proc_txts_write(struct file *file, const char *buf,
return count;
}
struct file_operations bksync_proc_txts_file_ops = {
owner: THIS_MODULE,
open: bksync_proc_txts_open,
read: seq_read,
llseek: seq_lseek,
write: bksync_proc_txts_write,
release: seq_release,
struct proc_ops bksync_proc_txts_file_ops = {
proc_open: bksync_proc_txts_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bksync_proc_txts_write,
proc_release: seq_release,
};
/*
@ -1641,13 +1640,12 @@ static int bksync_proc_debug_open(struct inode * inode, struct file * file)
}
struct file_operations bksync_proc_debug_file_ops = {
owner: THIS_MODULE,
open: bksync_proc_debug_open,
read: seq_read,
llseek: seq_lseek,
write: bksync_proc_debug_write,
release: single_release,
struct proc_ops bksync_proc_debug_file_ops = {
proc_open: bksync_proc_debug_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: bksync_proc_debug_write,
proc_release: single_release,
};

View File

@ -62,7 +62,7 @@ $(KMODULE): $(MODULE)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
# Make.depend is before clean:: so that Make.depend's clean:: runs first.

View File

@ -714,13 +714,12 @@ psample_proc_rate_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_rate_file_ops = {
owner: THIS_MODULE,
open: psample_proc_rate_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_rate_write,
release: single_release,
struct proc_ops psample_proc_rate_file_ops = {
proc_open: psample_proc_rate_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_rate_write,
proc_release: single_release,
};
/*
@ -813,13 +812,12 @@ psample_proc_size_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_size_file_ops = {
owner: THIS_MODULE,
open: psample_proc_size_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_size_write,
release: single_release,
struct proc_ops psample_proc_size_file_ops = {
proc_open: psample_proc_size_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_size_write,
proc_release: single_release,
};
/*
@ -854,13 +852,12 @@ psample_proc_map_open(struct inode * inode, struct file * file)
return single_open(file, psample_proc_map_show, NULL);
}
struct file_operations psample_proc_map_file_ops = {
owner: THIS_MODULE,
open: psample_proc_map_open,
read: seq_read,
llseek: seq_lseek,
write: NULL,
release: single_release,
struct proc_ops psample_proc_map_file_ops = {
proc_open: psample_proc_map_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: NULL,
proc_release: single_release,
};
/*
@ -924,13 +921,12 @@ psample_proc_debug_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_debug_file_ops = {
owner: THIS_MODULE,
open: psample_proc_debug_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_debug_write,
release: single_release,
struct proc_ops psample_proc_debug_file_ops = {
proc_open: psample_proc_debug_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_debug_write,
proc_release: single_release,
};
static int
@ -984,13 +980,12 @@ psample_proc_stats_write(struct file *file, const char *buf,
return count;
}
struct file_operations psample_proc_stats_file_ops = {
owner: THIS_MODULE,
open: psample_proc_stats_open,
read: seq_read,
llseek: seq_lseek,
write: psample_proc_stats_write,
release: single_release,
struct proc_ops psample_proc_stats_file_ops = {
proc_open: psample_proc_stats_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: psample_proc_stats_write,
proc_release: single_release,
};
int psample_cleanup(void)

View File

@ -149,6 +149,7 @@ static int _gmodule_proc_release(struct inode * inode, struct file * file) {
return single_release(inode, file);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct file_operations _gmodule_proc_fops = {
owner: THIS_MODULE,
open: _gmodule_proc_open,
@ -158,6 +159,15 @@ struct file_operations _gmodule_proc_fops = {
release: _gmodule_proc_release,
};
#else
struct proc_ops _gmodule_proc_fops = {
proc_open: _gmodule_proc_open,
proc_read: seq_read,
proc_lseek: seq_lseek,
proc_write: _gmodule_proc_write,
proc_release: _gmodule_proc_release,
};
#endif
#else
int
gmodule_vpprintf(char** page_ptr, const char* fmt, va_list args)
{
@ -271,7 +281,7 @@ _gmodule_release(struct inode *inode, struct file *filp)
return 0;
}
#ifdef HAVE_UNLOCKED_IOCTL
#if defined(HAVE_UNLOCKED_IOCTL) || LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
static long
_gmodule_unlocked_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
@ -334,7 +344,7 @@ _gmodule_mmap(struct file *filp, struct vm_area_struct *vma)
/* FILE OPERATIONS */
struct file_operations _gmodule_fops = {
#ifdef HAVE_UNLOCKED_IOCTL
#if defined(HAVE_UNLOCKED_IOCTL) || LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
unlocked_ioctl: _gmodule_unlocked_ioctl,
#else
ioctl: _gmodule_ioctl,

View File

@ -191,9 +191,9 @@ sal_sem_give(sal_sem_t b)
uint32
sal_time_usecs(void)
{
struct timeval ltv;
do_gettimeofday(&ltv);
return (ltv.tv_sec * SECOND_USEC + ltv.tv_usec);
// ktime_to_us and ktime_get_real_ns return 64-bit integets, but this
// function is returning a 32-bit integer. This should be fine until 2038.
return ktime_to_us(ktime_get_real_ns());
}
void