1

I'm trying to compile Sangoma's wanpipe driver v7.0.32 on Ubuntu 21.04 with kernel v5.11 for use with my A200 telephony card. The driver was written to support kernel 5.8. I have successfully built it using the 5.8 kernel but would prefer to be able to continue using the 5.11 kernel so I don't have to downgrade my production server.

I lack the C++ knowledge to sort out how to get past "positional initialization of field in 'struct' and "''struct file_operation' having no member named 'ioctl' errors in compiling the wanpipe driver.

Here is the result of make:

make KBUILD_VERBOSE=0 KBUILD_MODPOST_WARN=1 -C /lib/modules/5.11.0-22-generic/build M=/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net EXTRA_FLAGS="-I/usr/src/wanpipe-7.0.32/patches/kdrivers/include -I/usr/src/wanpipe-7.0.32/patches/kdrivers/include/annexg -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec -D__LINUX__ -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec/oct6100_api -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec/oct6100_api/include  -DCONFIG_PRODUCT_WANPIPE_BASE -DCONFIG_PRODUCT_WANPIPE_AFT -DCONFIG_PRODUCT_WANPIPE_AFT_CORE  -DCONFIG_PRODUCT_WANPIPE_AFT_TE1 -DCONFIG_PRODUCT_WANPIPE_AFT_TE3 -DCONFIG_PRODUCT_WANPIPE_AFT_56K -DCONFIG_WANPIPE_HWEC  -DCONFIG_PRODUCT_WANPIPE_SOCK_DATASCOPE -DCONFIG_PRODUCT_WANPIPE_AFT_BRI -DCONFIG_PRODUCT_WANPIPE_AFT_SERIAL  -DCONFIG_PRODUCT_WANPIPE_TDM_VOICE_DCHAN -DCONFIG_PRODUCT_WANPIPE_CODEC_SLINEAR_LAW -DCONFIG_PRODUCT_WANPIPE_AFT_RM  -DCONFIG_PRODUCT_WANPIPE_USB -DCONFIG_PRODUCT_WANPIPE_A700 -DCONFIG_PRODUCT_A600 -DCONFIG_PRODUCT_WANPIPE_AFT_A600 -DCONFIG_PRODUCT_WANPIPE_AFT_A700 -DCONFIG_PRODUCT_WANPIPE_AFT_B601 -DCONFIG_PRODUCT_WANPIPE_AFT_B800  -I/lib/modules/5.11.0-22-generic/build/include/linux -I/usr/src/dahdi  -DKERN_PROC_PDE_FEATURE=2 -DKERN_MEMCPY_FROM_MSG=1 -DKERN_MEMCPY_TO_MSG=1 -DKERN_SK_FOR_NODE_FEATURE=0 -DKERN_NETIF_TRANS_UPDATE=1 -DKERN_NDO_CHANGE_MTU_RH74=0 -DKERN_CLASS_DEV_GROUPS=1 -DKERN_TIMER_SETUP=2 -DKERN_REFCNT_UPDATE=3 -DKERN_SIG_UPDATE=11 -DKERN_CLASS_PROTO_OPS_UPDATE=0 -DKERN_DEV_CHG_FLAG_UPDATE=2 -DKERN_NDO_TIMEOUT_UPDATE=2 -DKERN_DO_GET_TIME=0 -DKERN_GET_KENEL_DS=0 -DKERN_PROC_CREATE=0 -DKERN_TIMER_32BIT=0  -DWANPIPE_USE_I_PRIVATE " ZAPDIR= ZAPHDLC= HOMEDIR=/usr/src/wanpipe-7.0.32 modules  
make[1]: Entering directory '/usr/src/linux-headers-5.11.0-22-generic'
  CC [M]  /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.o
In file included from /usr/src/wanpipe-7.0.32/patches/kdrivers/include/wanpipe_defines.h:30,
                 from /usr/src/wanpipe-7.0.32/patches/kdrivers/include/wanpipe_cdev_iface.h:9,
                 from /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:16:
/usr/src/wanpipe-7.0.32/patches/kdrivers/include/wanpipe_kernel.h:96:25: error: ‘struct file_operations’ has no member named ‘ioctl’
   96 | #define WAN_IOCTL       ioctl
      |                         ^~~~~
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:2: note: in expansion of macro ‘WAN_IOCTL’
  133 |  WAN_IOCTL: wp_cdev_ioctl,
      |  ^~~~~~~~~
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
  133 |  WAN_IOCTL: wp_cdev_ioctl,
      |             ^~~~~~~~~~~~~
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: note: (near initialization for ‘wp_cdev_fops’)
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: error: initialization of ‘int (*)(struct file *, loff_t,  loff_t,  int)’ {aka ‘int (*)(struct file *, long long int,  long long int,  int)’} from incompatible pointer type ‘int (*)(struct inode *, struct file *, unsigned int,  long unsigned int)’ [-Werror=incompatible-pointer-types]
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: note: (near initialization for ‘wp_cdev_fops.fsync’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:287: /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.o] Error 1
make[1]: *** [Makefile:1848: /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.11.0-22-generic'
make: *** [Makefile:399: all_kmod] Error 2

wanpipe_cdev_linux.c portion:

    /*=========================================================
 * Static Defines
 *=========================================================*/

static struct file_operations wp_cdev_fops = {
        owner: THIS_MODULE,
        llseek: NULL,
        open: wp_cdev_open,
        release: wp_cdev_release,
        WAN_IOCTL: wp_cdev_ioctl,
        read: wp_cdev_read,
        write: wp_cdev_write,
        poll: wp_cdev_poll,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
        compat_ioctl: wp_cdev_compat_ioctl,
#endif

wanpipe_kernel.h:

/////////////2.6.36/////////////////////////////
#ifdef HAVE_UNLOCKED_IOCTL
#define WAN_IOCTL       unlocked_ioctl
#define WAN_IOCTL_RET_TYPE      long
#define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct_ptr_file, cmd, data)
#else
#define WAN_IOCTL       ioctl
#define WAN_IOCTL_RET_TYPE      int
#define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct inode *inode, struct_ptr_file, cmd, data)
#endif
////////////////////////////////////////////////

Any help is appreciated.

hans109h
  • 11
  • 2
  • It seems the driver is **misconfigured**: It follows the branch `#else` (and uses `#define WAN_IOCTL ioctl)` while Linux kernel 5.11 [has](https://elixir.bootlin.com/linux/v5.11.6/source/include/linux/fs.h#L1831) `unlocked_ioctl` method, so `HAVE_UNLOCKED_IOCTL` should be defined. – Tsyvarev Jul 17 '21 at 10:31

2 Answers2

1

The previous code for wanpipe is only for kernel version 2.6.36 or less than that. In ubuntu 21.04 ,they have made some changes wrt kernel 5.8. In 5.8 or above kernel version, there is no ioctl function pointer in file operations. Instead they are using unlocked_ioctl. The following change will eradicate the error. You can check with the same. Thanks !

#if  ((LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,36)))
        #ifndef HAVE_UNLOCKED_IOCTL2
        #define HAVE_UNLOCKED_IOCTL2
                #define WAN_IOCTL       unlocked_ioctl
                #define WAN_IOCTL_RET_TYPE      long
                #define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct_ptr_file, cmd, data)
        #endif
#else
        #ifndef HAVE_UNLOCKED_IOCTL2
        #define HAVE_UNLOCKED_IOCTL2
                #define WAN_IOCTL       unlocked_ioctl
                #define WAN_IOCTL_RET_TYPE      long
                #define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct_ptr_file, cmd, data)
        #else
        #       define WAN_IOCTL       ioctl
        #       define WAN_IOCTL_RET_TYPE       int
        #       define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct inode *inode, struct_ptr_file, cmd, data)
        #endif

#endif
0

https://github.com/torvalds/linux/commit/4e24566a134ea167441a1ffa3d439a27cf400880

HAVE_UNLOCKED_IOCTL is not defined. Once I removed all ifdef HAVE_UNLOCKED_IOCTL references I was able to get past this problem. Thanks @Tsyvarel for pointing me in a direction.

hans109h
  • 11
  • 2