Drumfix / avb4linux

58 stars 15 forks source link

Incompatible pointer types when compiling #19

Closed Mystfit closed 2 years ago

Mystfit commented 2 years ago

I'm trying to build this but I'm getting a few compiler errors in the igb library.

Most errors seem to relate to skb_frag_ structs being incompatible pointer types. Am I missing a dependency?

Machine: Up Core Plus x86-64 single-board computer OS: Ubuntu 20.04 Compiler gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1\~20.04) Kernel: Linux vstup-1 5.4.0-1-generic #0~upboard5-Ubuntu SMP Fri Jan 7 11:53:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Ethernet: Intel i210 Ethernet controller on a Net Core Plus daughter board

Make log:

cd `pwd`/kernel-module/igb
make -C /lib/modules/`uname -r`/build M=`pwd`/kernel-module/igb
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-1-generic'
  CC [M]  /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.o
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:2400:22: error: initialization of ‘u16 (*)(struct net_device *, struct sk_buff *, struct net_device *)’ {aka ‘short unsigned int (*)(struct net_device *, struct sk_buff *, struct net_device *)’} from incompatible pointer type ‘u16 (*)(struct net_device *, struct sk_buff *, struct net_device *, u16 (*)(struct net_device *, struct sk_buff *, struct net_device *))’ {aka ‘short unsigned int (*)(struct net_device *, struct sk_buff *, struct net_device *, short unsigned int (*)(struct net_device *, struct sk_buff *, struct net_device *))’} [-Werror=incompatible-pointer-types]
 2400 |  .ndo_select_queue = igb_select_queue,
      |                      ^~~~~~~~~~~~~~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:2400:22: note: (near initialization for ‘igb_netdev_ops.ndo_select_queue’)
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: In function ‘igb_tx_map’:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:5583:12: error: assignment to ‘struct skb_frag_struct *’ from incompatible pointer type ‘skb_frag_t *’ {aka ‘struct bio_vec *’} [-Werror=incompatible-pointer-types]
 5583 |  for (frag = &skb_shinfo(skb)->frags[0];; frag++) {
      |            ^
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:5583:47: error: increment of pointer to an incomplete type ‘struct skb_frag_struct’
 5583 |  for (frag = &skb_shinfo(skb)->frags[0];; frag++) {
      |                                               ^~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:5624:24: error: passing argument 1 of ‘skb_frag_size’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 5624 |   size = skb_frag_size(frag);
      |                        ^~~~
      |                        |
      |                        struct skb_frag_struct *
In file included from ./include/linux/if_ether.h:19,
                 from ./include/uapi/linux/ethtool.h:19,
                 from ./include/linux/ethtool.h:18,
                 from ./include/linux/netdevice.h:37,
                 from /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:48:
./include/linux/skbuff.h:325:60: note: expected ‘const skb_frag_t *’ {aka ‘const struct bio_vec *’} but argument is of type ‘struct skb_frag_struct *’
  325 | static inline unsigned int skb_frag_size(const skb_frag_t *frag)
      |                                          ~~~~~~~~~~~~~~~~~~^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:5627:40: error: passing argument 2 of ‘skb_frag_dma_map’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 5627 |   dma = skb_frag_dma_map(tx_ring->dev, frag, 0,
      |                                        ^~~~
      |                                        |
      |                                        struct skb_frag_struct *
In file included from ./include/linux/if_ether.h:19,
                 from ./include/uapi/linux/ethtool.h:19,
                 from ./include/linux/ethtool.h:18,
                 from ./include/linux/netdevice.h:37,
                 from /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:48:
./include/linux/skbuff.h:3070:26: note: expected ‘const skb_frag_t *’ {aka ‘const struct bio_vec *’} but argument is of type ‘struct skb_frag_struct *’
 3070 |        const skb_frag_t *frag,
      |        ~~~~~~~~~~~~~~~~~~^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: At top level:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:5840:12: error: conflicting types for ‘igb_select_queue’
 5840 | static u16 igb_select_queue(struct net_device *dev, struct sk_buff *skb,
      |            ^~~~~~~~~~~~~~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:147:12: note: previous declaration of ‘igb_select_queue’ was here
  147 | static u16 igb_select_queue(struct net_device *dev, struct sk_buff *skb,
      |            ^~~~~~~~~~~~~~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: In function ‘igb_pull_tail’:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:8625:33: error: initialization of ‘struct skb_frag_struct *’ from incompatible pointer type ‘skb_frag_t *’ {aka ‘struct bio_vec *’} [-Werror=incompatible-pointer-types]
 8625 |  struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[0];
      |                                 ^
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:8633:24: error: passing argument 1 of ‘skb_frag_address’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 8633 |  va = skb_frag_address(frag);
      |                        ^~~~
      |                        |
      |                        struct skb_frag_struct *
In file included from ./include/linux/if_ether.h:19,
                 from ./include/uapi/linux/ethtool.h:19,
                 from ./include/linux/ethtool.h:18,
                 from ./include/linux/netdevice.h:37,
                 from /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:48:
./include/linux/skbuff.h:2998:56: note: expected ‘const skb_frag_t *’ {aka ‘const struct bio_vec *’} but argument is of type ‘struct skb_frag_struct *’
 2998 | static inline void *skb_frag_address(const skb_frag_t *frag)
      |                                      ~~~~~~~~~~~~~~~~~~^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:8641:21: error: passing argument 1 of ‘skb_frag_size_sub’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 8641 |   skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
      |                     ^~~~
      |                     |
      |                     struct skb_frag_struct *
In file included from ./include/linux/if_ether.h:19,
                 from ./include/uapi/linux/ethtool.h:19,
                 from ./include/linux/ethtool.h:18,
                 from ./include/linux/netdevice.h:37,
                 from /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:48:
./include/linux/skbuff.h:355:50: note: expected ‘skb_frag_t *’ {aka ‘struct bio_vec *’} but argument is of type ‘struct skb_frag_struct *’
  355 | static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
      |                                      ~~~~~~~~~~~~^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:8645:7: error: dereferencing pointer to incomplete type ‘struct skb_frag_struct’
 8645 |   frag->page_offset += IGB_TS_HDR_LEN;
      |       ^~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:8665:20: error: passing argument 1 of ‘skb_frag_size_sub’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 8665 |  skb_frag_size_sub(frag, pull_len);
      |                    ^~~~
      |                    |
      |                    struct skb_frag_struct *
In file included from ./include/linux/if_ether.h:19,
                 from ./include/uapi/linux/ethtool.h:19,
                 from ./include/linux/ethtool.h:18,
                 from ./include/linux/netdevice.h:37,
                 from /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:48:
./include/linux/skbuff.h:355:50: note: expected ‘skb_frag_t *’ {aka ‘struct bio_vec *’} but argument is of type ‘struct skb_frag_struct *’
  355 | static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
      |                                      ~~~~~~~~~~~~^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: In function ‘igb_io_error_detected’:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:9702:3: error: implicit declaration of function ‘pci_aer_clear_nonfatal_status’ [-Werror=implicit-function-declaration]
 9702 |   pci_aer_clear_nonfatal_status(pdev); /* pci_cleanup_aer_uncorrect_error_status(pdev); */
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: At top level:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:147:12: warning: ‘igb_select_queue’ used but never defined
  147 | static u16 igb_select_queue(struct net_device *dev, struct sk_buff *skb,
      |            ^~~~~~~~~~~~~~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: In function ‘igb_set_interrupt_capability’:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:1147:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
 1147 |   igb_reset_interrupt_capability(adapter);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:1148:2: note: here
 1148 |  case IGB_INT_MODE_MSI:
      |  ^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: In function ‘__igb_notify_dca’:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:6475:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
 6475 |   if (dca_add_requester(dev) == E1000_SUCCESS) {
      |      ^
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:6482:2: note: here
 6482 |  case DCA_PROVIDER_REMOVE:
      |  ^~~~
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c: In function ‘igb_has_link’:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:4800:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
 4800 |   if (!hw->mac.get_link_status)
      |      ^
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:4802:2: note: here
 4802 |  case e1000_media_type_internal_serdes:
      |  ^~~~
At top level:
/home/vstup/Code/avb4linux/kernel-module/igb/igb_main.c:5840:12: warning: ‘igb_select_queue’ defined but not used [-Wunused-function]
 5840 | static u16 igb_select_queue(struct net_device *dev, struct sk_buff *skb,
      |            ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:275: /home/vstup/Code/avb4linux/kernel-module/igb/igb_main.o] Error 1
make[1]: *** [Makefile:1757: /home/vstup/Code/avb4linux/kernel-module/igb] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-1-generic'
make: *** [Makefile:35: igb] Error 2
Drumfix commented 2 years ago

I don't update with every change of the kernel. But in your case (kernel 5.4.0) the following may help:

in igb_main.c change all occurences of `

if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,2)`

to

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)

and in the function igb_io_error_detected comment out (or delete) the whole part

#ifdef CONFIG_PCI_IOV
...
#endif /* CONFIG_PCI_IOV */
Mystfit commented 2 years ago

Thanks for that! I've gone through and commented out some other things to try and get this up and running but I've probably broken some things in the process.

My Motu Ultralite AVB can now see the AVB stream but I'm constantly getting new/join events which I'm unsure if that's indicative of a successful connection. Not sure if I've put the correct MAC addresses into avb-config.h

I'm using Carla to test the the input/output audio using ALSA but no sound is being received or transmitted back to the Motu yet.

/* configuration data for the AVB stream */

/* currently we use the locally administered MAAP MAC address base for our Talker stream */

#define MAAP_LOCALLY_ADMINISTRATORED_BASE 0x91e0f000fe00ul

#define OWN_TALKER_MAC_BASE MAAP_LOCALLY_ADMINISTRATORED_BASE

/* Set the MAC address of the i210 */

#define OWN_MAC 0x0007327b1af7ul

/* Note: The following can be drived by looking at the maap announce messages */
/*       of the AVB device using wireshark (set the filter for maap)          */

/* The MAC address of the remote AVB device */

#define AVB_DEVICE_SOURCE_MAC 0x0001f200ea90ul

/* The MAAP MAC address used by the AVB device for its Talker stream */

#define AVB_DEVICE_TALKER_MAC_BASE 0x91e0f000a2d5ul

The log from avb_up.sh

root@vstup-1:~# avb_up.sh enp5s0 48000
rmmod: ERROR: Module igb_avb is not currently loaded
driver: igb_avb
version: 5.3.2_AVB
firmware-version: 3.25, 0x800005d0
expansion-rom-version: 
bus-info: 0000:05:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no
Starting daemons on enp5s0
INFO     : GPTP [00:42:51:651] gPTP starting
ERROR    : GPTP [00:42:51:653] Using clock device: /dev/ptp2
STATUS   : GPTP [00:42:51:653] Starting PDelay
process_events()
ERROR    : GPTP [00:42:51:751] Error (TX) timestamping PDelay request, error=-72    
STATUS   : GPTP [00:42:52:198] LINKUP
STATUS   : GPTP [00:42:52:199] Link Speed: 100000 kb/sec
STATUS   : GPTP [00:42:53:244] AsCapable: Enabled
STATUS   : GPTP [00:42:54:653] *** Announce Timeout Expired - Becoming Master
STATUS   : GPTP [00:42:54:653] New Grandmaster "00:07:32:FF:FE:7B:1A:F7" (previous "00:00:00:00:00:00:00:00")
index=9
PARSE: C=6,P=3,V=0002
rc = 0, mrp_register_domain
PARSE: I=0002

rc = 0, mrp_join_vlan
Setting samplerate to 48000.
VNE 0002 R=000000000000 VN/MT

VNE 0002 R=000000000000 VN/MT
 unhandled from mrpd
SJO D:C=6,P=3,V=0002,N=3 R=0001f200ea90 AA/IN

SJO D:C=6,P=3,V=0002,N=3 R=0001f200ea90 AA/IN

Done setting samplerate.

Mac: 00-07-32-7b-1a-f7
S+L:L=0001f200ea900000, D=2
rc = 0, done sending ready
rc = 0, advertising stream
PARSE: L=0001f200ea900000, D=2
PARSE: S=0007327b1af70000,A=91e0f000fe00,V=0002,Z=224,I=1,P=112,L=95
SNE L:D=2,S=0001f200ea900000 R=000000000000 VN/MT

EVENT on STREAM ID=0001f200ea900000 with state ready
got a new/join indication
listener:
mode JOIN
stream: 0001f200ea900000
listener: 000000000000
SNE L:D=2,S=0001f200ea900000 R=000000000000 VN/MT

SNE T:S=0007327b1af70000,A=91e0f000fe00,V=0002,Z=224,I=1,P=112,L=95 R=000000000000 VN/MT

talker:
mode JOIN
stream: 0007327b1af70000
dst_mac: 91e0f000fe00
vid: 2
SNE T:S=0007327b1af70000,A=91e0f000fe00,V=0002,Z=224,I=1,P=112,L=95 R=000000000000 VN/MT

talker 1f2fffe00ea90, entity 732fffe7b1af7
SNE L:D=2,S=0007327b1af70000 R=0001f200ea90 VO/IN

EVENT on STREAM ID=0007327b1af70000 with state ready
got a new/join indication
listener:
mode JOIN
stream: 0007327b1af70000
listener: 0001f200ea90
SNE L:D=2,S=0007327b1af70000 R=0001f200ea90 VO/IN

VNE 0002 R=0001f200ea90 AA/IN

VNE 0002 R=0001f200ea90 AA/IN
 unhandled from mrpd
VNE 0002 R=0001f200ea90 QA/IN

VNE 0002 R=0001f200ea90 QA/IN
 unhandled from mrpd
SNE L:D=2,S=0007327b1af70000 R=0001f200ea90 VO/IN

EVENT on STREAM ID=0007327b1af70000 with state ready
got a new/join indication
listener:
mode JOIN
stream: 0007327b1af70000
listener: 0001f200ea90
SNE L:D=2,S=0007327b1af70000 R=0001f200ea90 VO/IN

VNE 0002 R=0001f200ea90 QA/IN

VNE 0002 R=0001f200ea90 QA/IN
 unhandled from mrpd
SNE T:S=0001f200ea900000,A=91e0f000a2d5,V=0002,Z=224,I=1,P=112,L=95 R=0001f200ea90 VO/IN

talker:
mode JOIN
stream: 0001f200ea900000
dst_mac: 91e0f000a2d5
vid: 2
SNE T:S=0001f200ea900000,A=91e0f000a2d5,V=0002,Z=224,I=1,P=112,L=95 R=0001f200ea90 VO/IN

VNE 0002 R=0001f200ea90 QA/IN

VNE 0002 R=0001f200ea90 QA/IN
 unhandled from mrpd
SNE T:S=0001f200ea900000,A=91e0f000a2d5,V=0002,Z=224,I=1,P=112,L=95 R=0001f200ea90 VO/IN

talker:
mode JOIN
stream: 0001f200ea900000
dst_mac: 91e0f000a2d5
vid: 2
SNE T:S=0001f200ea900000,A=91e0f000a2d5,V=0002,Z=224,I=1,P=112,L=95 R=0001f200ea90 VO/IN

VJO 0002 R=0001f200ea90 QA/IN

VJO 0002 R=0001f200ea90 QA/IN
 unhandled from mrpd
SNE L:D=2,S=0007327b1af70000 R=0001f200ea90 VO/IN

EVENT on STREAM ID=0007327b1af70000 with state ready
got a new/join indication
listener:
mode JOIN
stream: 0007327b1af70000
listener: 0001f200ea90
SNE L:D=2,S=0007327b1af70000 R=0001f200ea90 VO/IN

VNE 0002 R=0001f200ea90 AA/IN
...
Drumfix commented 2 years ago

That's odd. after the VJO you should only get VJO and SJO instead of VNE and SNE.

Do you see any activity for AVB-0 in the Motu routing matrix when trying to playback anything through alsa ?

Mystfit commented 2 years ago

My apologies, I managed to get audio going but it was an unrelated issue! I was routing audio from the Motu to Carla, but I've done further testing with Audacity and managed to get it to both record audio and playback on the Motu. So it's my Carla routing that is the issue.

In the ALSA audio driver device picker in Carla, I have either 2 or 3 instances (it changes) of hw:AVB,0 show up but regardless of which one I pick, I can't send or receive audio.

In comparison, audacity gives me a list of

AVB: - (hw:1,0)
AVB: - (hw:3,0)
AVB: - (hw:4,0)

but I can only record and play on AVB: - (hw:3,0)

Mystfit commented 2 years ago

Ok, I managed to get audio working in Carla using PulseAudio using the last AVB device that showed up in the input and output device lists. Sound is generally fine, but every several seconds there is a loud click which sounds like a single sample out of place.

Drumfix commented 2 years ago

You can set the PRESENTATION_TIME_OFFSET (wich means added latency) in alsa.c to a higher value. Probably start at 1000000 (1ms). Also, if you use a kernel with threaded irqs, set the threat priority of the NICs tx/rx-0 irq thread to a high value (e,g, 80).

Mystfit commented 2 years ago

Closing this issue as the original problem was fixed by dropping the version numbers for some kernel version checks down to 5.4 I've circumvented this by installing the latest Ubuntu Studio. Still haven't fixed the clicks yet but that's not related to this issue.