Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile for Linux 4.18 #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/C/common/nf2util.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ int closeDescriptor(struct nf2device *nf2);
void nf2_read_info(struct nf2device *nf2);
void printHello (struct nf2device *nf2, int *val);
unsigned getCPCIVersion(struct nf2device *nf2);
unsigned getCPCIRevsion(struct nf2device *nf2);
unsigned getCPCIRevision(struct nf2device *nf2);
unsigned getDeviceCPCIVersion(struct nf2device *nf2);
unsigned getDeviceCPCIRevsion(struct nf2device *nf2);
unsigned getDeviceCPCIRevision(struct nf2device *nf2);
unsigned getDeviceID(struct nf2device *nf2);
unsigned getDeviceMajor(struct nf2device *nf2);
unsigned getDeviceMinor(struct nf2device *nf2);
Expand Down
3 changes: 2 additions & 1 deletion lib/C/download/nf_download.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* Usage: ./nf_download <code filename>
*/

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -447,7 +448,7 @@ void VerifyDevInfo(void) {
nf2_read_info(&nf2);

/* Print the device information */
printf(getDeviceInfoStr(&nf2));
printf("%s", getDeviceInfoStr(&nf2));

/* Check the CPCI version info */
if (getDeviceID(&nf2) == -1) {
Expand Down
20 changes: 18 additions & 2 deletions lib/C/kernel/nf2_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* Description: Control card functionality
*
* Change history:
* 2/25/2019 - Denton Liu
* Added support for kernels 4.18 and beyond
* 3/10/10 - Paul Rodman & Maciej Żenczykowski
* Added support for kernels 2.6.31 and beyond
* (net_device api deprecated)
Expand Down Expand Up @@ -322,7 +324,11 @@ static int nf2c_tx(struct sk_buff *skb, struct net_device *dev)
nf2c_send(dev);

/* save the timestamp */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
netif_trans_update(dev);
#else
dev->trans_start = jiffies;
#endif
}

/*err_unlock:*/
Expand Down Expand Up @@ -706,7 +712,13 @@ static void nf2c_tx_timeout(struct net_device *dev)
u32 enable, intmask;

printk(KERN_ALERT "nf2: Transmit timeout on %s at %lu, latency %lu\n",
dev->name, jiffies, jiffies - dev->trans_start);
dev->name, jiffies, jiffies -
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
dev_trans_start(dev)
#else
dev->trans_start
#endif
);

iface->stats.tx_errors++;

Expand Down Expand Up @@ -1234,7 +1246,11 @@ int nf2c_probe(struct pci_dev *pdev, const struct pci_device_id *id,
for (i = 0; i < MAX_IFACE; i++) {
netdev = card->ndev[i] = alloc_netdev(
sizeof(struct nf2_iface_priv),
devname, nf2c_init);
devname,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
NET_NAME_UNKNOWN,
#endif
nf2c_init);
if (netdev == NULL) {
printk(KERN_ERR "nf2: Could not allocate ethernet "
"device.\n");
Expand Down
12 changes: 11 additions & 1 deletion lib/C/kernel/nf2_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/version.h>

/**
* nf2_get_settings - get settings for ethtool
Expand Down Expand Up @@ -96,10 +97,19 @@ static const struct ethtool_ops nf2_ethtool_ops = {
.set_settings = nf2_set_settings,
.get_drvinfo = nf2_get_drvinfo,
.get_link = ethtool_op_get_link,
.phys_id = nf2_phys_id,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
.set_phys_id
#else
.phys_id
#endif
= nf2_phys_id,
};

void nf2_set_ethtool_ops(struct net_device *dev)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
dev->ethtool_ops = &nf2_ethtool_ops;
#else
SET_ETHTOOL_OPS(dev, &nf2_ethtool_ops);
#endif
}
1 change: 1 addition & 0 deletions lib/C/reg_access/regread.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* Description: Reads a register
*/

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions lib/C/reg_access/regwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* Description: Write a register
*/

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down
3 changes: 2 additions & 1 deletion lib/C/tools/nf_info/nf_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* Description: Test program to dump the CPCI registers
*/

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -97,7 +98,7 @@ int main(int argc, char *argv[])
*/
void display_info(struct nf2device *nf2)
{
printf(getDeviceInfoStr(nf2));
printf("%s", getDeviceInfoStr(nf2));
}


Expand Down