From 1ae1f8b52343288f3985e2ac5c31c50d405ffecf Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Mon, 25 Feb 2019 10:51:12 -0800 Subject: [PATCH 1/4] common: s/Revsion/Revision/ nf2util.h used to contain several misspellings of "Revision", spelled "Revsion". Correct the misspellings to silence a warning about implicit declarations. Signed-off-by: Denton Liu --- lib/C/common/nf2util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/C/common/nf2util.h b/lib/C/common/nf2util.h index 1e8f2b6d..5a679237 100644 --- a/lib/C/common/nf2util.h +++ b/lib/C/common/nf2util.h @@ -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); From b34f05a6ff5c43b001c3b4713374b588aeef78c2 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Mon, 25 Feb 2019 10:51:48 -0800 Subject: [PATCH 2/4] download: include missing ctype.h We were using isprint in several places but we didn't include ctype.h. Include ctype.h to silence implicit declaration warnings. Signed-off-by: Denton Liu --- lib/C/download/nf_download.c | 1 + lib/C/reg_access/regread.c | 1 + lib/C/reg_access/regwrite.c | 1 + lib/C/tools/nf_info/nf_info.c | 1 + 4 files changed, 4 insertions(+) diff --git a/lib/C/download/nf_download.c b/lib/C/download/nf_download.c index c825358c..7e10c43e 100755 --- a/lib/C/download/nf_download.c +++ b/lib/C/download/nf_download.c @@ -39,6 +39,7 @@ * Usage: ./nf_download */ +#include #include #include #include diff --git a/lib/C/reg_access/regread.c b/lib/C/reg_access/regread.c index ec0f6ede..c91f4b66 100644 --- a/lib/C/reg_access/regread.c +++ b/lib/C/reg_access/regread.c @@ -38,6 +38,7 @@ * Description: Reads a register */ +#include #include #include #include diff --git a/lib/C/reg_access/regwrite.c b/lib/C/reg_access/regwrite.c index 7668a42e..e047b459 100644 --- a/lib/C/reg_access/regwrite.c +++ b/lib/C/reg_access/regwrite.c @@ -38,6 +38,7 @@ * Description: Write a register */ +#include #include #include #include diff --git a/lib/C/tools/nf_info/nf_info.c b/lib/C/tools/nf_info/nf_info.c index 7c7001a4..b17625ac 100644 --- a/lib/C/tools/nf_info/nf_info.c +++ b/lib/C/tools/nf_info/nf_info.c @@ -40,6 +40,7 @@ * Description: Test program to dump the CPCI registers */ +#include #include #include #include From 15a210f8a6c0943ef5c37a55f2c14a9be6b43623 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Mon, 25 Feb 2019 10:52:30 -0800 Subject: [PATCH 3/4] C: fix format string security warning gcc was warning about format not being a string literal with no format arguments. Silence those warnings by doing -printf(func()) +printf("%s", func()) Signed-off-by: Denton Liu --- lib/C/download/nf_download.c | 2 +- lib/C/tools/nf_info/nf_info.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/C/download/nf_download.c b/lib/C/download/nf_download.c index 7e10c43e..e13df2a3 100755 --- a/lib/C/download/nf_download.c +++ b/lib/C/download/nf_download.c @@ -448,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) { diff --git a/lib/C/tools/nf_info/nf_info.c b/lib/C/tools/nf_info/nf_info.c index b17625ac..6edb50c5 100644 --- a/lib/C/tools/nf_info/nf_info.c +++ b/lib/C/tools/nf_info/nf_info.c @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) */ void display_info(struct nf2device *nf2) { - printf(getDeviceInfoStr(nf2)); + printf("%s", getDeviceInfoStr(nf2)); } From ae39c127dba05a48ebf7419d7bdf36ba7b2d8e5d Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Mon, 25 Feb 2019 12:58:43 -0800 Subject: [PATCH 4/4] kernel: enable compilation for Linux 4.18 The kernel headers were updated such that we couldn't compile netfpga using the new headers. Update code using preprocessor statements to be compatible with new headers. Here is a reference of kernel commits that introduced breaking changes: 4d659fcb20d3 ("Merge branch 'kill_trans_start'", 2016-05-04) c835a6773314 ("net: set name_assign_type in alloc_netdev()", 2014-07-14) 1ab7b6ac2709 ("ethtool: remove phys_id from ethtool_ops", 2011-04-14) 7ad24ea4bf62 ("net: get rid of SET_ETHTOOL_OPS", 2014-05-11) Signed-off-by: Denton Liu --- lib/C/kernel/nf2_control.c | 20 ++++++++++++++++++-- lib/C/kernel/nf2_ethtool.c | 12 +++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/C/kernel/nf2_control.c b/lib/C/kernel/nf2_control.c index 9d18e651..01549b85 100644 --- a/lib/C/kernel/nf2_control.c +++ b/lib/C/kernel/nf2_control.c @@ -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) @@ -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:*/ @@ -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++; @@ -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"); diff --git a/lib/C/kernel/nf2_ethtool.c b/lib/C/kernel/nf2_ethtool.c index 092ab749..51be1cc2 100644 --- a/lib/C/kernel/nf2_ethtool.c +++ b/lib/C/kernel/nf2_ethtool.c @@ -42,6 +42,7 @@ #include #include +#include /** * nf2_get_settings - get settings for ethtool @@ -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 }