diff options
author | David Cemin <david.cemin@coveloz.com> | 2016-01-18 16:51:58 -0500 |
---|---|---|
committer | David Cemin <david.cemin@coveloz.com> | 2016-01-18 16:51:58 -0500 |
commit | 53c0b2b8c56e4f83a3b6f53076ab6d954cbe8a8a (patch) | |
tree | 197ebde8663e15b919c3385bd61ac4c8bce81a0b | |
parent | efb699685e515b4b82d84c4fcd6b2b75a6cbbc37 (diff) | |
parent | 390d5db43a44f6ec20c4ca3ced32ce745a0c8c98 (diff) | |
download | Open-AVB-53c0b2b8c56e4f83a3b6f53076ab6d954cbe8a8a.tar.gz |
Merge remote-tracking branch 'upstream/open-avb-next' into open-avb-next
41 files changed, 498 insertions, 290 deletions
diff --git a/daemons/gptp/linux/src/linux_hal_i210.cpp b/daemons/gptp/linux/src/linux_hal_i210.cpp index 124d075c..03e489ad 100644 --- a/daemons/gptp/linux/src/linux_hal_i210.cpp +++ b/daemons/gptp/linux/src/linux_hal_i210.cpp @@ -140,10 +140,6 @@ bool LinuxTimestamperGeneric::HWTimestamper_PPS_start( ) { ctrl |= 0x400000; // set bit 22 SDP0 enabling output igb_writereg(&igb_private->igb_dev, IGB_CTRL, ctrl ); - igb_readreg( &igb_private->igb_dev, TSAUXC, &tsauxc ); - tsauxc |= 0x14; - igb_writereg( &igb_private->igb_dev, TSAUXC, tsauxc ); - igb_readreg(&igb_private->igb_dev, TSSDP, &tssdp); tssdp &= ~0x40; // Set SDP0 output to freq clock 0 tssdp |= 0x80; @@ -152,20 +148,24 @@ bool LinuxTimestamperGeneric::HWTimestamper_PPS_start( ) { igb_readreg(&igb_private->igb_dev, TSSDP, &tssdp); tssdp |= 0x100; // set bit 8 -> SDP0 Time Sync Output igb_writereg(&igb_private->igb_dev, TSSDP, tssdp); - + + igb_readreg( &igb_private->igb_dev, TSAUXC, &tsauxc ); + tsauxc |= 0x14; + igb_writereg( &igb_private->igb_dev, TSAUXC, tsauxc ); + igb_unlock( &igb_private->igb_dev ); return true; } bool LinuxTimestamperGeneric::HWTimestamper_PPS_stop() { - unsigned tssdp; - + unsigned tsauxc; + if( !igb_private->igb_initd ) return false; - - igb_readreg(&igb_private->igb_dev, TSSDP, &tssdp); - tssdp &= ~0x100; // set bit 8 -> SDP0 Time Sync Output - igb_writereg(&igb_private->igb_dev, TSSDP, tssdp); - + + igb_readreg( &igb_private->igb_dev, TSAUXC, &tsauxc ); + tsauxc &= ~0x14; // set bit 4 and bit 2 -> AUXC ST0 and EN_CLK0 + igb_writereg( &igb_private->igb_dev, TSAUXC, tsauxc ); + return true; } diff --git a/kmod/igb/kcompat.c b/kmod/igb/kcompat.c index 13bfda9e..c905fd3c 100644 --- a/kmod/igb/kcompat.c +++ b/kmod/igb/kcompat.c @@ -1059,21 +1059,19 @@ void _kc_netif_tx_start_all_queues(struct net_device *netdev) } #endif /* HAVE_TX_MQ */ -#ifndef __WARN_printf void __kc_warn_slowpath(const char *file, int line, const char *fmt, ...) { va_list args; printk(KERN_WARNING "------------[ cut here ]------------\n"); - printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file, line); + printk(KERN_WARNING "WARNING: at %s:%d \n", file, line); va_start(args, fmt); vprintk(fmt, args); va_end(args); dump_stack(); } -#endif /* __WARN_printf */ -#endif /* < 2.6.27 */ +#endif /* __VMKLNX__ */ /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) ) @@ -1166,17 +1164,18 @@ int _kc_pci_num_vf(struct pci_dev __maybe_unused *dev) #ifdef HAVE_TX_MQ #if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0))) #ifndef CONFIG_NETDEVICES_MULTIQUEUE -void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) +int _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) { unsigned int real_num = dev->real_num_tx_queues; struct Qdisc *qdisc; int i; - if (unlikely(txq > dev->num_tx_queues)) - ; + if (txq < 1 || txq > dev->num_tx_queues) + return -EINVAL; + else if (txq > real_num) dev->real_num_tx_queues = txq; - else if ( txq < real_num) { + else if (txq < real_num) { dev->real_num_tx_queues = txq; for (i = txq; i < dev->num_tx_queues; i++) { qdisc = netdev_get_tx_queue(dev, i)->qdisc; @@ -1187,6 +1186,8 @@ void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) } } } + + return 0; } #endif /* CONFIG_NETDEVICES_MULTIQUEUE */ #endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */ @@ -1544,6 +1545,62 @@ int __kc_pci_vfs_assigned(struct pci_dev __maybe_unused *dev) #endif /* CONFIG_PCI_IOV */ #endif /* 3.10.0 */ +/*****************************************************************************/ +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) ) +const unsigned char pcie_link_speed[] = { + PCI_SPEED_UNKNOWN, /* 0 */ + PCIE_SPEED_2_5GT, /* 1 */ + PCIE_SPEED_5_0GT, /* 2 */ + PCIE_SPEED_8_0GT, /* 3 */ + PCI_SPEED_UNKNOWN, /* 4 */ + PCI_SPEED_UNKNOWN, /* 5 */ + PCI_SPEED_UNKNOWN, /* 6 */ + PCI_SPEED_UNKNOWN, /* 7 */ + PCI_SPEED_UNKNOWN, /* 8 */ + PCI_SPEED_UNKNOWN, /* 9 */ + PCI_SPEED_UNKNOWN, /* A */ + PCI_SPEED_UNKNOWN, /* B */ + PCI_SPEED_UNKNOWN, /* C */ + PCI_SPEED_UNKNOWN, /* D */ + PCI_SPEED_UNKNOWN, /* E */ + PCI_SPEED_UNKNOWN /* F */ +}; + +int __kc_pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, + enum pcie_link_width *width) +{ + int ret; + + *speed = PCI_SPEED_UNKNOWN; + *width = PCIE_LNK_WIDTH_UNKNOWN; + + while (dev) { + u16 lnksta; + enum pci_bus_speed next_speed; + enum pcie_link_width next_width; + + ret = pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta); + if (ret) + return ret; + + next_speed = pcie_link_speed[lnksta & PCI_EXP_LNKSTA_CLS]; + next_width = (lnksta & PCI_EXP_LNKSTA_NLW) >> + PCI_EXP_LNKSTA_NLW_SHIFT; + + if (next_speed < *speed) + *speed = next_speed; + + if (next_width < *width) + *width = next_width; + + dev = dev->bus->self; + } + + return 0; +} + +#endif + #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) ) int __kc_dma_set_mask_and_coherent(struct device *dev, u64 mask) { diff --git a/kmod/igb/kcompat.h b/kmod/igb/kcompat.h index 845f5baa..ab9d8600 100644 --- a/kmod/igb/kcompat.h +++ b/kmod/igb/kcompat.h @@ -2021,12 +2021,6 @@ static inline int _kc_skb_padto(struct sk_buff *skb, unsigned int len) /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) ) - -/* other values will be created as #defines later */ -enum pci_bus_speed { - PCI_SPEED_UNKNOWN = 0xff, -}; - enum pcie_link_width { PCIE_LNK_WIDTH_RESRV = 0x00, PCIE_LNK_X1 = 0x01, @@ -2743,6 +2737,13 @@ static inline void __kc_skb_queue_head_init(struct sk_buff_head *list) #define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */ +#ifndef PCI_EXP_LNKSTA_CLS +#define PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */ +#endif +#ifndef PCI_EXP_LNKSTA_NLW +#define PCI_EXP_LNKSTA_NLW 0x03f0 /* Negotiated Link Width */ +#endif + #ifndef pci_clear_master extern void _kc_pci_clear_master(struct pci_dev *dev); #define pci_clear_master(dev) _kc_pci_clear_master(dev) @@ -3204,9 +3205,20 @@ static inline bool _kc_pm_runtime_suspended(struct device __always_unused *dev) #endif #endif /* 2.6.0 => 2.6.34 */ -#define PCIE_SPEED_2_5GT 0x14 -#define PCIE_SPEED_5_0GT 0x15 -#define PCIE_SPEED_8_0GT 0x16 +#ifndef pci_bus_speed +/* override pci_bus_speed introduced in 2.6.19 with an expanded enum type */ +enum _kc_pci_bus_speed { + _KC_PCIE_SPEED_2_5GT = 0x14, + _KC_PCIE_SPEED_5_0GT = 0x15, + _KC_PCIE_SPEED_8_0GT = 0x16, + _KC_PCI_SPEED_UNKNOWN = 0xff, +}; +#define pci_bus_speed _kc_pci_bus_speed +#define PCIE_SPEED_2_5GT _KC_PCIE_SPEED_2_5GT +#define PCIE_SPEED_5_0GT _KC_PCIE_SPEED_5_0GT +#define PCIE_SPEED_8_0GT _KC_PCIE_SPEED_8_0GT +#define PCI_SPEED_UNKNOWN _KC_PCI_SPEED_UNKNOWN +#endif /* pci_bus_speed */ #else /* < 2.6.34 */ #define HAVE_SYSTEM_SLEEP_PM_OPS @@ -3232,22 +3244,29 @@ ssize_t _kc_simple_write_to_buffer(void *to, size_t available, loff_t *ppos, #ifndef numa_mem_id #define numa_mem_id numa_node_id #endif +#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0))) #ifdef HAVE_TX_MQ #include <net/sch_generic.h> #ifndef CONFIG_NETDEVICES_MULTIQUEUE -#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0))) -void _kc_netif_set_real_num_tx_queues(struct net_device *, unsigned int); -#define netif_set_real_num_tx_queues _kc_netif_set_real_num_tx_queues -#endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */ +int _kc_netif_set_real_num_tx_queues(struct net_device *, unsigned int); #else /* CONFIG_NETDEVICES_MULTI_QUEUE */ -#define netif_set_real_num_tx_queues(_netdev, _count) \ - do { \ - (_netdev)->egress_subqueue_count = _count; \ - } while (0) +static inline int _kc_netif_set_real_num_tx_queues(struct net_device *dev, + unsigned int txq) +{ + dev->egress_subqueue_count = txq; + return 0; +} #endif /* CONFIG_NETDEVICES_MULTI_QUEUE */ #else /* HAVE_TX_MQ */ -#define netif_set_real_num_tx_queues(_netdev, _count) do {} while(0) +static inline int _kc_netif_set_real_num_tx_queues(struct net_device __always_unused *dev, + unsigned int __always_unused txq) +{ + return 0; +} #endif /* HAVE_TX_MQ */ +#define netif_set_real_num_tx_queues(dev, txq) \ + _kc_netif_set_real_num_tx_queues(dev, txq) +#endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */ #ifndef ETH_FLAG_RXHASH #define ETH_FLAG_RXHASH (1<<28) #endif /* ETH_FLAG_RXHASH */ @@ -3341,6 +3360,16 @@ static inline void skb_tx_timestamp(struct sk_buff __always_unused *skb) /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) ) +#ifndef netif_set_real_num_tx_queues +static inline int _kc_netif_set_real_num_tx_queues(struct net_device *dev, + unsigned int txq) +{ + netif_set_real_num_tx_queues(dev, txq); + return 0; +} +#define netif_set_real_num_tx_queues(dev, txq) \ + _kc_netif_set_real_num_tx_queues(dev, txq) +#endif #ifndef netif_set_real_num_rx_queues static inline int __kc_netif_set_real_num_rx_queues(struct net_device __always_unused *dev, unsigned int __always_unused rxq) @@ -4074,6 +4103,51 @@ static inline bool __kc_is_link_local_ether_addr(const u8 *addr) /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) ) +#undef BUILD_BUG_ON +#ifdef __CHECKER__ +#define BUILD_BUG_ON(condition) (0) +#else /* __CHECKER__ */ +#ifndef __compiletime_warning +#if defined(__GNUC__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400) +#define __compiletime_warning(message) __attribute__((warning(message))) +#else /* __GNUC__ */ +#define __compiletime_warning(message) +#endif /* __GNUC__ */ +#endif /* __compiletime_warning */ +#ifndef __compiletime_error +#if defined(__GNUC__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400) +#define __compiletime_error(message) __attribute__((error(message))) +#define __compiletime_error_fallback(condition) do { } while (0) +#else /* __GNUC__ */ +#define __compiletime_error(message) +#define __compiletime_error_fallback(condition) \ + do { ((void)sizeof(char[1 - 2 * condition])); } while (0) +#endif /* __GNUC__ */ +#else /* __compiletime_error */ +#define __compiletime_error_fallback(condition) do { } while (0) +#endif /* __compiletime_error */ +#define __compiletime_assert(condition, msg, prefix, suffix) \ + do { \ + bool __cond = !(condition); \ + extern void prefix ## suffix(void) __compiletime_error(msg); \ + if (__cond) \ + prefix ## suffix(); \ + __compiletime_error_fallback(__cond); \ + } while (0) + +#define _compiletime_assert(condition, msg, prefix, suffix) \ + __compiletime_assert(condition, msg, prefix, suffix) +#define compiletime_assert(condition, msg) \ + _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) +#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) +#ifndef __OPTIMIZE__ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#else /* __OPTIMIZE__ */ +#define BUILD_BUG_ON(condition) \ + BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) +#endif /* __OPTIMIZE__ */ +#endif /* __CHECKER__ */ + #undef hlist_entry #define hlist_entry(ptr, type, member) container_of(ptr,type,member) @@ -4178,6 +4252,10 @@ extern int __kc_ndo_dflt_fdb_del(struct ndmsg *ndm, struct net_device *dev, /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) ) +#if ((RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,6)) ||\ + (SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(11,4,0))) +#define HAVE_NDO_SET_VF_LINK_STATE +#endif #else /* >= 3.11.0 */ #define HAVE_NDO_SET_VF_LINK_STATE #define HAVE_SKB_INNER_PROTOCOL @@ -4259,11 +4337,7 @@ static inline void __kc_skb_set_hash(struct sk_buff __maybe_unused *skb, } #endif /* !skb_set_hash */ -#else - -#ifndef HAVE_ENCAP_TSO_OFFLOAD -#define HAVE_ENCAP_TSO_OFFLOAD -#endif /* HAVE_ENCAP_TSO_OFFLOAD */ +#else /* RHEL_RELEASE_CODE >= 7.0 || SLE_VERSION_CODE >= 12.0 */ #ifndef HAVE_VXLAN_RX_OFFLOAD #define HAVE_VXLAN_RX_OFFLOAD @@ -4272,7 +4346,7 @@ static inline void __kc_skb_set_hash(struct sk_buff __maybe_unused *skb, #ifndef HAVE_VXLAN_CHECKS #define HAVE_VXLAN_CHECKS #endif /* HAVE_VXLAN_CHECKS */ -#endif /* !(RHEL_RELEASE_CODE&&RHEL_RELEASE_CODE>=RHEL_RELEASE_VERSION(7,0)) */ +#endif /* !(RHEL_RELEASE_CODE >= 7.0 && SLE_VERSION_CODE >= 12.0) */ #ifndef pci_enable_msix_range extern int __kc_pci_enable_msix_range(struct pci_dev *dev, @@ -4474,6 +4548,12 @@ extern unsigned int __kc_eth_get_headlen(unsigned char *data, unsigned int max_l /* netdev_phys_port_id renamed to netdev_phys_item_id */ #define netdev_phys_item_id netdev_phys_port_id +static inline void _kc_napi_complete_done(struct napi_struct *napi, + int __always_unused work_done) { + napi_complete(napi); +} +#define napi_complete_done _kc_napi_complete_done + #ifndef NETDEV_RSS_KEY_LEN #define NETDEV_RSS_KEY_LEN (13 * 4) #endif @@ -4526,18 +4606,23 @@ static inline int __kc_eth_skb_pad(struct sk_buff *skb) #define eth_skb_pad(skb) __kc_eth_skb_pad(skb) #endif /* eth_skb_pad && skb_put_padto */ -#ifndef napi_alloc_skb +#ifndef SKB_ALLOC_NAPI +/* RHEL 7.2 backported napi_alloc_skb and friends */ static inline struct sk_buff *__kc_napi_alloc_skb(struct napi_struct *napi, unsigned int length) { return netdev_alloc_skb_ip_align(napi->dev, length); } #define napi_alloc_skb(napi,len) __kc_napi_alloc_skb(napi,len) -#endif /* napi_alloc_skb */ +#define __napi_alloc_skb(napi,len,mask) __kc_napi_alloc_skb(napi,len) +#endif /* SKB_ALLOC_NAPI */ #define HAVE_CONFIG_PM_RUNTIME #if RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(7,1)) #define NDO_DFLT_BRIDGE_GETLINK_HAS_BRFLAGS #define HAVE_RXFH_HASHFUNC #endif /* RHEL_RELEASE_CODE */ +#ifndef napi_schedule_irqoff +#define napi_schedule_irqoff napi_schedule +#endif #else /* 3.19.0 */ #define HAVE_NDO_FDB_ADD_VID #define HAVE_RXFH_HASHFUNC @@ -4576,9 +4661,10 @@ static inline void __kc_timecounter_adjtime(struct timecounter *tc, s64 delta) #else #define HAVE_PTP_CLOCK_INFO_GETTIME64 #define HAVE_NDO_BRIDGE_GETLINK_NLFLAGS +#define HAVE_PASSTHRU_FEATURES_CHECK #endif /* 4,1,0 */ -#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0) ) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,9)) #if (!(SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(12,1,0))) static inline bool page_is_pfmemalloc(struct page __maybe_unused *page) { @@ -4589,10 +4675,27 @@ static inline bool page_is_pfmemalloc(struct page __maybe_unused *page) #endif } #endif /* !SLES12sp1 */ +#else +#undef HAVE_STRUCT_PAGE_PFMEMALLOC +#endif /* 4.1.9 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)) #else #define HAVE_NDO_DFLT_BRIDGE_GETLINK_VLAN_SUPPORT -#undef HAVE_STRUCT_PAGE_PFMEMALLOC #endif /* 4.2.0 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0)) +#else +#define HAVE_NDO_SET_VF_TRUST +#endif /* 4.4.0 */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)) +/* protect against a likely backport */ +#ifndef NETIF_F_CSUM_MASK +#define NETIF_F_CSUM_MASK NETIF_F_ALL_CSUM +#endif /* NETIF_F_CSUM_MASK */ +#else +#define HAVE_GENEVE_RX_OFFLOAD +#endif /* 4.5.0 */ + #endif /* _KCOMPAT_H_ */ diff --git a/lib/avtp_pipeline/avtp/openavb_avtp.c b/lib/avtp_pipeline/avtp/openavb_avtp.c index 0fd4addb..6cf3ea8b 100644 --- a/lib/avtp_pipeline/avtp/openavb_avtp.c +++ b/lib/avtp_pipeline/avtp/openavb_avtp.c @@ -306,10 +306,7 @@ openavbRC openavbAvtpTx(void *pv, bool bSend, bool txBlockingInIntf) if (!pStream->pBuf) { pStream->pBuf = (U8 *)openavbRawsockGetTxFrame(pStream->rawsock, TRUE, &frameLen); - if (!pStream->pBuf) { - txCBResult = TX_CB_RET_PACKET_NOT_READY; - } - else { + if (pStream->pBuf) { assert(frameLen >= pStream->frameLen); // Fill in the Ethernet header openavbRawsockTxFillHdr(pStream->rawsock, pStream->pBuf, &pStream->ethHdrLen); @@ -446,7 +443,7 @@ openavbRC openavbAvtpRxInit( static void x_avtpRxFrame(avtp_stream_t *pStream, U8 *pFrame, U32 frameLen) { AVB_TRACE_ENTRY(AVB_TRACE_AVTP_DETAIL); - AVB_LOGF_DEBUG("pFrame=%8.8p, len=%u", pFrame, frameLen); + AVB_LOGF_DEBUG("pFrame=%p, len=%u", pFrame, frameLen); U8 subtype, flags, flags2, rxSeq, nLost, avtpVersion; U8 *pRead = pFrame; @@ -497,6 +494,10 @@ static void x_avtpRxFrame(avtp_stream_t *pStream, U8 *pFrame, U32 frameLen) // pStream->pIntfCB->intf_rx_cb(pStream->pMediaQ); pStream->info.rx.bComplete = TRUE; + + // to prevent unused variable warnings + (void)subtype; + (void)flags2; } else { AVB_RC_LOG(AVB_RC(OPENAVB_AVTP_FAILURE | OPENAVBAVTP_RC_INVALID_AVTP_VERSION)); diff --git a/lib/avtp_pipeline/avtp/openavb_avtp_time.c b/lib/avtp_pipeline/avtp/openavb_avtp_time.c index 345d0204..49581289 100644 --- a/lib/avtp_pipeline/avtp/openavb_avtp_time.c +++ b/lib/avtp_pipeline/avtp/openavb_avtp_time.c @@ -331,7 +331,7 @@ bool openavbAvtpTimeIsPast(avtp_time_t *pAvtpTime) if (nsNow + pAvtpTime->maxLatencyNsec < pAvtpTime->timeNsec) { IF_LOG_INTERVAL(100) { - AVB_LOGF_INFO("Timestamp out of range: Now:%llu TSTime%llu MaxLatency:%lluns Delta:%lluns", nsNow, pAvtpTime->timeNsec, pAvtpTime->maxLatencyNsec, pAvtpTime->timeNsec - nsNow); + AVB_LOGF_INFO("Timestamp out of range: Now:%" PRIu64 " TSTime%" PRIu64 " MaxLatency:%" PRIu64 "ns Delta:%" PRIu64 "ns", nsNow, pAvtpTime->timeNsec, pAvtpTime->maxLatencyNsec, pAvtpTime->timeNsec - nsNow); } return TRUE; } @@ -362,7 +362,7 @@ bool openavbAvtpTimeIsPastTime(avtp_time_t *pAvtpTime, U64 nSecTime) if (nSecTime + pAvtpTime->maxLatencyNsec < pAvtpTime->timeNsec) { IF_LOG_INTERVAL(100) { - AVB_LOGF_INFO("Timestamp out of range: Now:%llu TSTime%llu MaxLatency:%lluns Delta:%lluns", nSecTime, pAvtpTime->timeNsec, pAvtpTime->maxLatencyNsec, pAvtpTime->timeNsec - nSecTime); + AVB_LOGF_INFO("Timestamp out of range: Now:%" PRIu64 "TSTime%" PRIu64 " MaxLatency:%" PRIu64 " ns Delta:%" PRIu64 "ns", nSecTime, pAvtpTime->timeNsec, pAvtpTime->maxLatencyNsec, pAvtpTime->timeNsec - nSecTime); } return TRUE; } diff --git a/lib/avtp_pipeline/intf_ctrl/ctrl_talker.ini b/lib/avtp_pipeline/intf_ctrl/ctrl_talker.ini index ef33fa59..747ff19b 100644 --- a/lib/avtp_pipeline/intf_ctrl/ctrl_talker.ini +++ b/lib/avtp_pipeline/intf_ctrl/ctrl_talker.ini @@ -96,6 +96,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/intf_echo/echo_talker.ini b/lib/avtp_pipeline/intf_echo/echo_talker.ini index 69a0f988..6987e03c 100644 --- a/lib/avtp_pipeline/intf_echo/echo_talker.ini +++ b/lib/avtp_pipeline/intf_echo/echo_talker.ini @@ -93,6 +93,9 @@ report_seconds = 1 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/intf_echo/echo_talker_auto.ini b/lib/avtp_pipeline/intf_echo/echo_talker_auto.ini index d6ec7280..66326964 100644 --- a/lib/avtp_pipeline/intf_echo/echo_talker_auto.ini +++ b/lib/avtp_pipeline/intf_echo/echo_talker_auto.ini @@ -93,6 +93,9 @@ report_seconds = 1 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/intf_null/null_talker.ini b/lib/avtp_pipeline/intf_null/null_talker.ini index 088c2009..3f440cbd 100644 --- a/lib/avtp_pipeline/intf_null/null_talker.ini +++ b/lib/avtp_pipeline/intf_null/null_talker.ini @@ -93,6 +93,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/intf_tonegen/tonegen_talker.ini b/lib/avtp_pipeline/intf_tonegen/tonegen_talker.ini index dbbc9f2d..24a207c9 100644 --- a/lib/avtp_pipeline/intf_tonegen/tonegen_talker.ini +++ b/lib/avtp_pipeline/intf_tonegen/tonegen_talker.ini @@ -78,6 +78,9 @@ max_transit_usec = 2000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/intf_viewer/latency_talker.ini b/lib/avtp_pipeline/intf_viewer/latency_talker.ini index 823ae3b9..f69a6673 100644 --- a/lib/avtp_pipeline/intf_viewer/latency_talker.ini +++ b/lib/avtp_pipeline/intf_viewer/latency_talker.ini @@ -103,6 +103,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/map_aaf_audio/openavb_map_aaf_audio.c b/lib/avtp_pipeline/map_aaf_audio/openavb_map_aaf_audio.c index d9e3fc0c..d17788f1 100755 --- a/lib/avtp_pipeline/map_aaf_audio/openavb_map_aaf_audio.c +++ b/lib/avtp_pipeline/map_aaf_audio/openavb_map_aaf_audio.c @@ -60,6 +60,9 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175. // - 1 Byte - TU bit (timestamp uncertain) #define HIDX_AVTP_HIDE7_TU1 3 +// - 2 bytes Stream data length +#define HIDX_STREAM_DATA_LEN16 20 + // - 1 Byte - SP bit (sparse mode) #define HIDX_AVTP_HIDE7_SP 22 #define SP_M0_BIT (1 << 4) @@ -601,6 +604,14 @@ bool openavbMapAVTPAudioRxCB(media_q_t *pMediaQ, U8 *pData, U32 dataLen) bool listenerSparseMode = (pPvtData->sparseMode == TS_SPARSE_MODE_ENABLED) ? TRUE : FALSE; bool streamSparseMode = (pHdrV0[HIDX_AVTP_HIDE7_SP] & SP_M0_BIT) ? TRUE : FALSE; + U16 payloadLen = ntohs(*(U16 *)(&pHdrV0[HIDX_STREAM_DATA_LEN16])); + + if (payloadLen > dataLen - TOTAL_HEADER_SIZE) { + if (pPvtData->dataValid) + AVB_LOGF_ERROR("header data len %d > actual data len %d", + payloadLen, dataLen - TOTAL_HEADER_SIZE); + dataValid = FALSE; + } if ((tmp = ((format_info >> 24) & 0xFF)) != pPvtData->aaf_format) { if (pPvtData->dataValid) diff --git a/lib/avtp_pipeline/mediaq/openavb_mediaq.c b/lib/avtp_pipeline/mediaq/openavb_mediaq.c index d79b78fb..463b15c2 100644 --- a/lib/avtp_pipeline/mediaq/openavb_mediaq.c +++ b/lib/avtp_pipeline/mediaq/openavb_mediaq.c @@ -1054,6 +1054,7 @@ bool openavbMediaQAnyReadyItems(media_q_t *pMediaQ, bool ignoreTimestamp) U64 nSecTime; CLOCK_GETTIME64(OPENAVB_CLOCK_WALLTIME, &nSecTime); media_q_item_t *pTail = &pMediaQInfo->pItems[tailIdx]; + assert(pTail); if (!pTail->taken) { if (openavbAvtpTimeIsPastTime(pTail->pAvtpTime, nSecTime)) { diff --git a/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_client_osal.c b/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_client_osal.c index bbc0e2a2..dcdca3cd 100644 --- a/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_client_osal.c +++ b/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_client_osal.c @@ -51,7 +51,7 @@ static bool openavbEptClntSendToServer(int h, openavbEndpointMessage_t *msg) } ssize_t nWrite = write(h, msg, OPENAVB_ENDPOINT_MSG_LEN); - AVB_LOGF_VERBOSE("Sent message, len=%d, nWrite=%d", OPENAVB_ENDPOINT_MSG_LEN, nWrite); + AVB_LOGF_VERBOSE("Sent message, len=%zu, nWrite=%zu", OPENAVB_ENDPOINT_MSG_LEN, nWrite); if (nWrite < OPENAVB_ENDPOINT_MSG_LEN) { if (nWrite < 0) { diff --git a/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c b/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c index c2a4125d..c921d358 100644 --- a/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c +++ b/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c @@ -78,7 +78,7 @@ static bool openavbEptSrvrSendToClient(int h, openavbEndpointMessage_t *msg) } ssize_t nWrite = write(csock, msg, OPENAVB_ENDPOINT_MSG_LEN); - AVB_LOGF_VERBOSE("Sent message, len=%d, nWrite=%d", OPENAVB_ENDPOINT_MSG_LEN, nWrite); + AVB_LOGF_VERBOSE("Sent message, len=%zu, nWrite=%zu", OPENAVB_ENDPOINT_MSG_LEN, nWrite); if (nWrite < OPENAVB_ENDPOINT_MSG_LEN) { if (nWrite < 0) { AVB_LOGF_ERROR("Failed to write socket: %s", strerror(errno)); @@ -203,7 +203,7 @@ void openavbEptSrvrService(void) openavbEndpointMessage_t msgBuf; memset(&msgBuf, 0, OPENAVB_ENDPOINT_MSG_LEN); ssize_t nRead = read(csock, &msgBuf, OPENAVB_ENDPOINT_MSG_LEN); - AVB_LOGF_VERBOSE("Socket read h=%d,fd=%d: read=%d, expect=%d", i, csock, nRead, OPENAVB_ENDPOINT_MSG_LEN); + AVB_LOGF_VERBOSE("Socket read h=%d,fd=%d: read=%zu, expect=%zu", i, csock, nRead, OPENAVB_ENDPOINT_MSG_LEN); if (nRead < OPENAVB_ENDPOINT_MSG_LEN) { // sock closed diff --git a/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_file_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_file_talker.ini index ffa339a5..0eddb28f 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_file_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_file_talker.ini @@ -74,6 +74,9 @@ max_transit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_talker.ini index 40bb3e38..f98ba668 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_alsa/aaf_talker.ini @@ -89,6 +89,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/intf_alsa/alsa_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_alsa/alsa_talker.ini index 652b9704..e5908906 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_alsa/alsa_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_alsa/alsa_talker.ini @@ -87,6 +87,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/intf_h264_gst/openavb_intf_h264_gst.c b/lib/avtp_pipeline/platform/Linux/intf_h264_gst/openavb_intf_h264_gst.c index 9a7f08fb..35af240f 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_h264_gst/openavb_intf_h264_gst.c +++ b/lib/avtp_pipeline/platform/Linux/intf_h264_gst/openavb_intf_h264_gst.c @@ -402,7 +402,7 @@ static void *openavbIntfH264RtpGstRxThreadfn(void *pv) } else { - AVB_LOGF_INFO("The Buf %x %d skipped, OO!!", rxBuf, bufrd); + AVB_LOGF_INFO("The Buf %p %d skipped, OO!!", rxBuf, bufrd); } } else @@ -512,7 +512,7 @@ bool openavbIntfH264RtpGstRxCB(media_q_t *pMediaQ) if (mdif >= NBUFS) { openavbMediaQTailPull(pMediaQ); - AVB_LOGF_INFO("Rx async queue full, dropping (%lu - %lu = %lu)", bufwr, bufrd, mdif); + AVB_LOGF_INFO("Rx async queue full, dropping (%" PRIu32 " - %" PRIu32 " = %" PRIu32 ")", bufwr, bufrd, mdif); moreSourcePackets = FALSE; continue; } diff --git a/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/mjpeg_gst_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/mjpeg_gst_talker.ini index 05b8223e..7e906a76 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/mjpeg_gst_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/mjpeg_gst_talker.ini @@ -93,6 +93,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/openavb_intf_mjpeg_gst.c b/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/openavb_intf_mjpeg_gst.c index 52ee0a3e..db2aafa6 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/openavb_intf_mjpeg_gst.c +++ b/lib/avtp_pipeline/platform/Linux/intf_mjpeg_gst/openavb_intf_mjpeg_gst.c @@ -321,7 +321,7 @@ static void *openavbIntfMjpegGstRxThreadfn(void *pv) } else { - AVB_LOGF_INFO("The Buf %x %d skipped, OO!!", rxBuf, bufrd); + AVB_LOGF_INFO("The Buf %p %d skipped, OO!!", rxBuf, bufrd); } } else @@ -431,7 +431,7 @@ bool openavbIntfMjpegGstRxCB(media_q_t *pMediaQ) if (mdif >= NBUFS) { openavbMediaQTailPull(pMediaQ); - AVB_LOGF_INFO("Rx async queue full, dropping (%lu - %lu = %lu)", bufwr, bufrd, mdif); + AVB_LOGF_INFO("Rx async queue full, dropping (%" PRIu32 " - %" PRIu32 " = %" PRIu32 ")", bufwr, bufrd, mdif); moreSourcePackets = FALSE; continue; } @@ -467,7 +467,7 @@ bool openavbIntfMjpegGstRxCB(media_q_t *pMediaQ) // all fragments should have the same timestamp if(pPvtData->frame_timestamp != fragment_timestamp) { - AVB_LOGF_ERROR("Mapping is wrong. Fragment timestamp should be %lu instead of %lu", + AVB_LOGF_ERROR("Mapping is wrong. Fragment timestamp should be %" PRIu32 " instead of %" PRIu32, pPvtData->frame_timestamp, fragment_timestamp); } } diff --git a/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/mpeg2ts_file_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/mpeg2ts_file_talker.ini index c4f595a0..b5bf26d0 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/mpeg2ts_file_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/mpeg2ts_file_talker.ini @@ -93,6 +93,9 @@ raw_rx_buffers = 100 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/openavb_intf_mpeg2ts_file.c b/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/openavb_intf_mpeg2ts_file.c index b44ee9e1..311ec767 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/openavb_intf_mpeg2ts_file.c +++ b/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_file/openavb_intf_mpeg2ts_file.c @@ -498,7 +498,7 @@ double openavbIntfMpeg2tsFileComputeDuration(pvt_data_t* pPvtData, unsigned char pPvtData->fPIDStatusTable[idx].firstRealTime = timeNow; pPvtData->fPIDStatusTable[idx].lastRealTime = timeNow; pPvtData->fPIDStatusTable[idx].lastPacketNum = 0; - AVB_LOGF_VERBOSE("PID 0x%x, FIRST PCR 0x%08x+%d:%03x == %f @ %f, pkt #%lu\n", pid, pcrBaseHigh, pkt[10]>>7, pcrExt, fClock, timeNow, pPvtData->fTSPacketCount); + AVB_LOGF_VERBOSE("PID 0x%x, FIRST PCR 0x%08x+%d:%03x == %f @ %f, pkt #%lf\n", pid, pcrBaseHigh, pkt[10]>>7, pcrExt, fClock, timeNow, pPvtData->fTSPacketCount); } else { // We've seen this PID's PCR before; update our per-packet duration estimate: double packetsSinceLast = (pPvtData->fTSPacketCount -pPvtData->fPIDStatusTable[idx].lastPacketNum); @@ -535,7 +535,7 @@ double openavbIntfMpeg2tsFileComputeDuration(pvt_data_t* pPvtData, unsigned char pPvtData->fPIDStatusTable[idx].firstClock = fClock; pPvtData->fPIDStatusTable[idx].firstRealTime = timeNow; } - AVB_LOGF_VERBOSE("PID 0x%x, PCKT_CNT %lu PCR 0x%08x+%d:%03x == %f @ %f (diffs %f @ %f), pkt #%lu, discon %d => this duration %f, new estimate %f, mean PCR period=%f\n", + AVB_LOGF_VERBOSE("PID 0x%x, PCKT_CNT %lf PCR 0x%08x+%d:%03x == %f @ %f (diffs %f @ %f), pkt #%lf, discon %d => this duration %f, new estimate %f, mean PCR period=%f\n", pid, pPvtData->fTSPacketCount, pcrBaseHigh, pkt[10]>>7, pcrExt, fClock, timeNow, fClock - pPvtData->fPIDStatusTable[idx].firstClock, timeNow - pPvtData->fPIDStatusTable[idx].firstRealTime, pPvtData->fTSPacketCount, discontinuity_indicator != 0, durationPerPacket, pPvtData->fTSPacketDurationEstimate, meanPCRPeriod ); } pPvtData->fPIDStatusTable[idx].lastClock = fClock; diff --git a/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_gst/mpeg2ts_gst_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_gst/mpeg2ts_gst_talker.ini index fa48e7a3..0cc3299b 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_gst/mpeg2ts_gst_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_mpeg2ts_gst/mpeg2ts_gst_talker.ini @@ -83,6 +83,9 @@ max_transmit_deficit_usec = 50000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/intf_wav_file/wav_file_talker.ini b/lib/avtp_pipeline/platform/Linux/intf_wav_file/wav_file_talker.ini index ead3bbfc..9abe8167 100644 --- a/lib/avtp_pipeline/platform/Linux/intf_wav_file/wav_file_talker.ini +++ b/lib/avtp_pipeline/platform/Linux/intf_wav_file/wav_file_talker.ini @@ -78,6 +78,9 @@ max_transit_usec = 2000 # Ethernet Interface Name. Only needed on some platforms when stack is built with no endpoint functionality # ifname = eth0 +# vlan_id: VLAN Identifier (1-4094). Used in "no endpoint" builds. Defaults to 2. +# vlan_id = 2 + ##################################################################### # Mapping module configuration ##################################################################### diff --git a/lib/avtp_pipeline/platform/Linux/openavb_os_services_osal.h b/lib/avtp_pipeline/platform/Linux/openavb_os_services_osal.h index 36a3171f..e3833f0d 100644 --- a/lib/avtp_pipeline/platform/Linux/openavb_os_services_osal.h +++ b/lib/avtp_pipeline/platform/Linux/openavb_os_services_osal.h @@ -124,7 +124,7 @@ thread##_type thread##_ThreadData error=FALSE; \ if (threadhandle##_ThreadData.err != 0) \ { \ - AVB_LOGF_ERROR("Thread error: %s code:", message, threadhandle##_ThreadData.err); \ + AVB_LOGF_ERROR("Thread error: %s code: %d", message, threadhandle##_ThreadData.err); \ error=TRUE; \ break; \ } \ diff --git a/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c b/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c index 832f4bc1..281527e7 100644 --- a/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c +++ b/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c @@ -77,8 +77,8 @@ static bool x_timeInit(void) { return FALSE;
}
- AVB_LOGF_INFO("local_time = %llu", gPtpTD.local_time);
- AVB_LOGF_INFO("ml_phoffset = %lld, ls_phoffset = %lld", gPtpTD.ml_phoffset, gPtpTD.ls_phoffset);
+ AVB_LOGF_INFO("local_time = %" PRIu64, gPtpTD.local_time);
+ AVB_LOGF_INFO("ml_phoffset = %" PRId64 ", ls_phoffset = %" PRId64, gPtpTD.ml_phoffset, gPtpTD.ls_phoffset);
AVB_LOGF_INFO("ml_freqffset = %Lf, ls_freqoffset = %Lf", gPtpTD.ml_freqoffset, gPtpTD.ls_freqoffset);
AVB_TRACE_EXIT(AVB_TRACE_TIME);
diff --git a/lib/avtp_pipeline/platform/Linux/rawsock/igb_rawsock.c b/lib/avtp_pipeline/platform/Linux/rawsock/igb_rawsock.c index 4c702634..cbb6ce80 100644 --- a/lib/avtp_pipeline/platform/Linux/rawsock/igb_rawsock.c +++ b/lib/avtp_pipeline/platform/Linux/rawsock/igb_rawsock.c @@ -49,27 +49,11 @@ void *igbRawsockOpen(igb_rawsock_t* rawsock, const char *ifname, bool rx_mode, b { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - if (rx_mode) { - if (!pcapRawsockOpen((pcap_rawsock_t*)rawsock, ifname, rx_mode, - false, ethertype, frame_size, num_frames)) - { - AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); - return NULL; - } - rawsock->base.txMode = tx_mode; - } else { - rawsock->handle = 0; - rawsock->base.rxMode = rx_mode; - rawsock->base.txMode = tx_mode; - rawsock->base.ethertype = ethertype; - - // Get info about the network device - if (!simpleAvbCheckInterface(ifname, &(rawsock->base.ifInfo))) { - AVB_LOGF_ERROR("Creating rawsock; bad interface name: %s", ifname); - free(rawsock); - AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); - return NULL; - } + if (!pcapRawsockOpen((pcap_rawsock_t*)rawsock, ifname, rx_mode, + tx_mode, ethertype, frame_size, num_frames)) + { + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); + return NULL; } if (tx_mode) { @@ -94,6 +78,18 @@ void *igbRawsockOpen(igb_rawsock_t* rawsock, const char *ifname, bool rx_mode, b rawsock->queue = 1; } + // fill virtual functions table + rawsock_cb_t *cb = &rawsock->base.cb; + cb->close = igbRawsockClose; + cb->getTxFrame = igbRawsockGetTxFrame; + cb->relTxFrame = igbRawsockRelTxFrame; + cb->txSetMark = igbRawsockTxSetMark; + cb->txFrameReady = igbRawsockTxFrameReady; + cb->send = igbRawsockSend; + cb->txBufLevel = igbRawsockTxBufLevel; + cb->getTXOutOfBuffers = igbRawsockGetTXOutOfBuffers; + cb->getTXOutOfBuffersCyclic = igbRawsockGetTXOutOfBuffersCyclic; + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return rawsock; } diff --git a/lib/avtp_pipeline/platform/Linux/rawsock/openavb_rawsock.c b/lib/avtp_pipeline/platform/Linux/rawsock/openavb_rawsock.c index 52376abf..b73d9e7b 100644 --- a/lib/avtp_pipeline/platform/Linux/rawsock/openavb_rawsock.c +++ b/lib/avtp_pipeline/platform/Linux/rawsock/openavb_rawsock.c @@ -95,27 +95,6 @@ void *openavbRawsockOpen(const char *ifname_uri, bool rx_mode, bool tx_mode, U16 return NULL; } - // fill virtual functions table - rawsock_cb_t *cb = &rawsock->base.cb; - cb->close = ringRawsockClose; - cb->getTxFrame = ringRawsockGetTxFrame; - cb->txSetMark = simpleRawsockTxSetMark; - cb->txSetHdr = simpleRawsockTxSetHdr; - cb->txFillHdr = baseRawsockTxFillHdr; - cb->relTxFrame = ringRawsockRelTxFrame; - cb->txFrameReady = ringRawsockTxFrameReady; - cb->send = ringRawsockSend; - cb->txBufLevel = ringRawsockTxBufLevel; - cb->rxBufLevel = ringRawsockRxBufLevel; - cb->getRxFrame = ringRawsockGetRxFrame; - cb->rxParseHdr = ringRawsockRxParseHdr; - cb->relRxFrame = ringRawsockRelRxFrame; - cb->rxMulticast = simpleRawsockRxMulticast; - cb->getSocket = simpleRawsockGetSocket; - cb->getAddr = baseRawsockGetAddr; - cb->getTXOutOfBuffers = ringRawsockGetTXOutOfBuffers; - cb->getTXOutOfBuffersCyclic = ringRawsockGetTXOutOfBuffersCyclic; - // call constructor pvRawsock = ringRawsockOpen(rawsock, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames); @@ -130,20 +109,6 @@ void *openavbRawsockOpen(const char *ifname_uri, bool rx_mode, bool tx_mode, U16 return NULL; } - // fill virtual functions table - rawsock_cb_t *cb = &rawsock->base.cb; - cb->close = simpleRawsockClose; - cb->getTxFrame = simpleRawsockGetTxFrame; - cb->txSetMark = simpleRawsockTxSetMark; - cb->txSetHdr = simpleRawsockTxSetHdr; - cb->txFillHdr = baseRawsockTxFillHdr; - cb->txFrameReady = simpleRawsockTxFrameReady; - cb->getRxFrame = simpleRawsockGetRxFrame; - cb->rxParseHdr = simpleRawsockRxParseHdr; - cb->rxMulticast = simpleRawsockRxMulticast; - cb->getSocket = simpleRawsockGetSocket; - cb->getAddr = baseRawsockGetAddr; - // call constructor pvRawsock = simpleRawsockOpen(rawsock, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames); #if AVB_FEATURE_PCAP @@ -158,18 +123,6 @@ void *openavbRawsockOpen(const char *ifname_uri, bool rx_mode, bool tx_mode, U16 return NULL; } - // fill virtual functions table - rawsock_cb_t *cb = &rawsock->base.cb; - cb->close = pcapRawsockClose; - cb->getTxFrame = pcapRawsockGetTxFrame; - cb->txSetHdr = baseRawsockTxSetHdr; - cb->txFillHdr = baseRawsockTxFillHdr; - cb->txFrameReady = pcapRawsockTxFrameReady; - cb->getRxFrame = pcapRawsockGetRxFrame; - cb->rxParseHdr = simpleRawsockRxParseHdr; - cb->rxMulticast = pcapRawsockRxMulticast; - cb->getAddr = baseRawsockGetAddr; - // call constructor pvRawsock = pcapRawsockOpen(rawsock, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames); #ifdef IGB @@ -184,24 +137,6 @@ void *openavbRawsockOpen(const char *ifname_uri, bool rx_mode, bool tx_mode, U16 return NULL; } - // fill virtual functions table - rawsock_cb_t *cb = &rawsock->base.cb; - cb->close = igbRawsockClose; - cb->getTxFrame = igbRawsockGetTxFrame; - cb->relTxFrame = igbRawsockRelTxFrame; - cb->txSetHdr = baseRawsockTxSetHdr; - cb->txSetMark = igbRawsockTxSetMark; - cb->txFillHdr = baseRawsockTxFillHdr; - cb->txFrameReady = igbRawsockTxFrameReady; - cb->send = igbRawsockSend; - cb->txBufLevel = igbRawsockTxBufLevel; - cb->getRxFrame = pcapRawsockGetRxFrame; - cb->rxParseHdr = simpleRawsockRxParseHdr; - cb->rxMulticast = pcapRawsockRxMulticast; - cb->getAddr = baseRawsockGetAddr; - cb->getTXOutOfBuffers = igbRawsockGetTXOutOfBuffers; - cb->getTXOutOfBuffersCyclic = igbRawsockGetTXOutOfBuffersCyclic; - // call constructor pvRawsock = igbRawsockOpen((igb_rawsock_t*)rawsock, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames); #endif diff --git a/lib/avtp_pipeline/platform/Linux/rawsock/pcap_rawsock.c b/lib/avtp_pipeline/platform/Linux/rawsock/pcap_rawsock.c index c1c302a8..3a4a1046 100644 --- a/lib/avtp_pipeline/platform/Linux/rawsock/pcap_rawsock.c +++ b/lib/avtp_pipeline/platform/Linux/rawsock/pcap_rawsock.c @@ -45,15 +45,13 @@ void *pcapRawsockOpen(pcap_rawsock_t* rawsock, const char *ifname, bool rx_mode, AVB_LOGF_DEBUG("Open, rx=%d, tx=%d, ethertype=%x size=%d, num=%d", rx_mode, tx_mode, ethertype, frame_size, num_frames); + baseRawsockOpen(&rawsock->base, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames); + if (tx_mode) { - AVB_LOG_ERROR("pcap rawsock transmit mode will bypass FQTSS"); + AVB_LOG_DEBUG("pcap rawsock transmit mode will bypass FQTSS"); } rawsock->handle = 0; - rawsock->base.rxMode = rx_mode; - rawsock->base.txMode = tx_mode; - rawsock->base.frameSize = frame_size; - rawsock->base.ethertype = ethertype; // Get info about the network device if (!simpleAvbCheckInterface(ifname, &(rawsock->base.ifInfo))) { @@ -66,9 +64,9 @@ void *pcapRawsockOpen(pcap_rawsock_t* rawsock, const char *ifname, bool rx_mode, // Deal with frame size. if (rawsock->base.frameSize == 0) { // use interface MTU as max frames size, if none specified - rawsock->base.frameSize = rawsock->base.ifInfo.mtu; + rawsock->base.frameSize = rawsock->base.ifInfo.mtu + ETH_HLEN + VLAN_HLEN; } - else if (rawsock->base.frameSize > rawsock->base.ifInfo.mtu) { + else if (rawsock->base.frameSize > rawsock->base.ifInfo.mtu + ETH_HLEN + VLAN_HLEN) { AVB_LOG_ERROR("Creating raswsock; requested frame size exceeds MTU"); free(rawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); @@ -84,6 +82,14 @@ void *pcapRawsockOpen(pcap_rawsock_t* rawsock, const char *ifname, bool rx_mode, return NULL; } + // fill virtual functions table + rawsock_cb_t *cb = &rawsock->base.cb; + cb->close = pcapRawsockClose; + cb->getTxFrame = pcapRawsockGetTxFrame; + cb->txFrameReady = pcapRawsockTxFrameReady; + cb->getRxFrame = pcapRawsockGetRxFrame; + cb->rxMulticast = pcapRawsockRxMulticast; + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return rawsock; } @@ -93,10 +99,10 @@ void pcapRawsockClose(void *pvRawsock) pcap_rawsock_t *rawsock = (pcap_rawsock_t*)pvRawsock; if (rawsock) { - if (rawsock->handle) - pcap_close(rawsock->handle); - free(rawsock); + pcap_close(rawsock->handle); } + + baseRawsockClose(rawsock); } U8 *pcapRawsockGetTxFrame(void *pvRawsock, bool blocking, unsigned int *len) diff --git a/lib/avtp_pipeline/platform/Linux/rawsock/ring_rawsock.c b/lib/avtp_pipeline/platform/Linux/rawsock/ring_rawsock.c index a8f09ba2..71c7a3af 100644 --- a/lib/avtp_pipeline/platform/Linux/rawsock/ring_rawsock.c +++ b/lib/avtp_pipeline/platform/Linux/rawsock/ring_rawsock.c @@ -43,8 +43,6 @@ void* ringRawsockOpen(ring_rawsock_t *rawsock, const char *ifname, bool rx_mode, { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - rawsock->pMem = (void*)(-1); - if (!simpleRawsockOpen((simple_rawsock_t*)rawsock, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames)) { @@ -52,6 +50,8 @@ void* ringRawsockOpen(ring_rawsock_t *rawsock, const char *ifname, bool rx_mode, return NULL; } + rawsock->pMem = (void*)(-1); + // Use version 2 headers for the MMAP packet stuff - avoids 32/64 // bit problems, gives nanosecond timestamps, and allows rx of vlan id int val = TPACKET_V2; @@ -77,7 +77,7 @@ void* ringRawsockOpen(ring_rawsock_t *rawsock, const char *ifname, bool rx_mode, } rawsock->bufferSize = rawsock->base.frameSize + rawsock->bufHdrSize; rawsock->frameCount = num_frames; - AVB_LOGF_DEBUG("frameSize=%d, bufHdrSize=%d(%d+%d) bufferSize=%d, frameCount=%d", + AVB_LOGF_DEBUG("frameSize=%d, bufHdrSize=%d(%d+%zu) bufferSize=%d, frameCount=%d", rawsock->base.frameSize, rawsock->bufHdrSize, val, sizeof(struct sockaddr_ll), rawsock->bufferSize, rawsock->frameCount); @@ -128,7 +128,7 @@ void* ringRawsockOpen(ring_rawsock_t *rawsock, const char *ifname, bool rx_mode, // Call MMAP to get access to the memory used for the ring rawsock->memSize = rawsock->blockCount * rawsock->blockSize; - AVB_LOGF_DEBUG("memSize=%d (%d, %d), sock=%d", + AVB_LOGF_DEBUG("memSize=%zu (%d, %d), sock=%d", rawsock->memSize, rawsock->blockCount, rawsock->blockSize, @@ -151,6 +151,21 @@ void* ringRawsockOpen(ring_rawsock_t *rawsock, const char *ifname, bool rx_mode, rawsock->buffersOut = 0; rawsock->buffersReady = 0; + // fill virtual functions table + rawsock_cb_t *cb = &rawsock->base.cb; + cb->close = ringRawsockClose; + cb->getTxFrame = ringRawsockGetTxFrame; + cb->relTxFrame = ringRawsockRelTxFrame; + cb->txFrameReady = ringRawsockTxFrameReady; + cb->send = ringRawsockSend; + cb->txBufLevel = ringRawsockTxBufLevel; + cb->rxBufLevel = ringRawsockRxBufLevel; + cb->getRxFrame = ringRawsockGetRxFrame; + cb->rxParseHdr = ringRawsockRxParseHdr; + cb->relRxFrame = ringRawsockRelRxFrame; + cb->getTXOutOfBuffers = ringRawsockGetTXOutOfBuffers; + cb->getTXOutOfBuffersCyclic = ringRawsockGetTXOutOfBuffersCyclic; + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return rawsock; } @@ -167,9 +182,10 @@ void ringRawsockClose(void *pvRawsock) munmap(rawsock->pMem, rawsock->memSize); rawsock->pMem = (void*)(-1); } - - simpleRawsockClose(pvRawsock); } + + simpleRawsockClose(pvRawsock); + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); } diff --git a/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.c b/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.c index 257ce2cc..385d57e6 100644 --- a/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.c +++ b/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.c @@ -130,11 +130,9 @@ void* simpleRawsockOpen(simple_rawsock_t* rawsock, const char *ifname, bool rx_m AVB_LOGF_DEBUG("Open, rx=%d, tx=%d, ethertype=%x size=%d, num=%d", rx_mode, tx_mode, ethertype, frame_size, num_frames); + baseRawsockOpen(&rawsock->base, ifname, rx_mode, tx_mode, ethertype, frame_size, num_frames); + rawsock->sock = -1; - rawsock->base.rxMode = rx_mode; - rawsock->base.txMode = tx_mode; - rawsock->base.frameSize = frame_size; - rawsock->base.ethertype = ethertype; // Get info about the network device if (!simpleAvbCheckInterface(ifname, &(rawsock->base.ifInfo))) { @@ -147,9 +145,9 @@ void* simpleRawsockOpen(simple_rawsock_t* rawsock, const char *ifname, bool rx_m // Deal with frame size. if (rawsock->base.frameSize == 0) { // use interface MTU as max frames size, if none specified - rawsock->base.frameSize = rawsock->base.ifInfo.mtu; + rawsock->base.frameSize = rawsock->base.ifInfo.mtu + ETH_HLEN + VLAN_HLEN; } - else if (rawsock->base.frameSize > rawsock->base.ifInfo.mtu) { + else if (rawsock->base.frameSize > rawsock->base.ifInfo.mtu + ETH_HLEN + VLAN_HLEN) { AVB_LOG_ERROR("Creating raswsock; requested frame size exceeds MTU"); free(rawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); @@ -195,6 +193,18 @@ void* simpleRawsockOpen(simple_rawsock_t* rawsock, const char *ifname, bool rx_m return NULL; } + + // fill virtual functions table + rawsock_cb_t *cb = &rawsock->base.cb; + cb->close = simpleRawsockClose; + cb->getTxFrame = simpleRawsockGetTxFrame; + cb->txSetMark = simpleRawsockTxSetMark; + cb->txSetHdr = simpleRawsockTxSetHdr; + cb->txFrameReady = simpleRawsockTxFrameReady; + cb->getRxFrame = simpleRawsockGetRxFrame; + cb->rxMulticast = simpleRawsockRxMulticast; + cb->getSocket = simpleRawsockGetSocket; + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return rawsock; } @@ -211,9 +221,10 @@ void simpleRawsockClose(void *pvRawsock) close(rawsock->sock); rawsock->sock = -1; } - // free the state struct - free(rawsock); } + + baseRawsockClose(rawsock); + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); } @@ -344,27 +355,6 @@ U8* simpleRawsockGetRxFrame(void *pvRawsock, U32 timeout, unsigned int *offset, return pBuffer; } -// Parse the ethernet frame header. Returns length of header, or -1 for failure -int simpleRawsockRxParseHdr(void *pvRawsock, U8 *pBuffer, hdr_info_t *pInfo) -{ - AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - - eth_hdr_t *eth_hdr = (eth_hdr_t*)pBuffer; - pInfo->dhost = eth_hdr->dhost; - pInfo->shost = eth_hdr->shost; - pInfo->ethertype = ntohs(eth_hdr->ethertype); - int hdrLen = sizeof(eth_hdr_t); - - if (pInfo->ethertype == ETHERTYPE_8021Q) { - pInfo->vlan = TRUE; - // TODO extract vlan_vid and vlan_pcp - hdrLen += 4; - } - - AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); - return hdrLen; -} - // Setup the rawsock to receive multicast packets bool simpleRawsockRxMulticast(void *pvRawsock, bool add_membership, const U8 addr[ETH_ALEN]) { diff --git a/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.h b/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.h index dacbceed..db0ef1f3 100644 --- a/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.h +++ b/lib/avtp_pipeline/platform/Linux/rawsock/simple_rawsock.h @@ -73,9 +73,6 @@ bool simpleRawsockTxFrameReady(void *pvRawsock, U8 *pBuffer, unsigned int len); // Get a RX frame U8* simpleRawsockGetRxFrame(void *pvRawsock, U32 timeout, unsigned int *offset, unsigned int *len); -// Parse the ethernet frame header. Returns length of header, or -1 for failure -int simpleRawsockRxParseHdr(void *pvRawsock, U8 *pBuffer, hdr_info_t *pInfo); - // Setup the rawsock to receive multicast packets bool simpleRawsockRxMulticast(void *pvRawsock, bool add_membership, const U8 addr[ETH_ALEN]); diff --git a/lib/avtp_pipeline/platform/Linux/tl/openavb_tl_osal.c b/lib/avtp_pipeline/platform/Linux/tl/openavb_tl_osal.c index 44d5b1c4..d6ca4264 100644 --- a/lib/avtp_pipeline/platform/Linux/tl/openavb_tl_osal.c +++ b/lib/avtp_pipeline/platform/Linux/tl/openavb_tl_osal.c @@ -303,6 +303,18 @@ static int openavbTLCfgCallback(void *user, const char *tlSection, const char *n valOK = TRUE; } } + else if (MATCH(name, "vlan_id")) { + errno = 0; + long tmp; + tmp = strtol(value, &pEnd, 0); + // vlanID is 12 bit field + if (*pEnd == '\0' && errno == 0 + && tmp >= 0x0 + && tmp <= 0xFFF) { + pCfg->vlan_id = tmp; + valOK = TRUE; + } + } else if (MATCH(name, "map_lib")) { if (pTLState->mapLib.libName) diff --git a/lib/avtp_pipeline/rawsock/rawsock_impl.c b/lib/avtp_pipeline/rawsock/rawsock_impl.c index a8259ea7..c351f47c 100644 --- a/lib/avtp_pipeline/rawsock/rawsock_impl.c +++ b/lib/avtp_pipeline/rawsock/rawsock_impl.c @@ -34,6 +34,67 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175. #define AVB_LOG_COMPONENT "Raw Socket" #include "openavb_log.h" +void baseRawsockSetRxSignalMode(void *rawsock, bool rxSignalMode) {} +int baseRawsockGetSocket(void *rawsock) { return -1; } +U8 *baseRawsockGetRxFrame(void *rawsock, U32 usecTimeout, U32 *offset, U32 *len) { return NULL; } +bool baseRawsockRelRxFrame(void *rawsock, U8 *pFrame) { return false; } +bool baseRawsockRxMulticast(void *rawsock, bool add_membership, const U8 buf[]) { return false; } +bool baseRawsockRxAVTPSubtype(void *rawsock, U8 subtype) { return false; } +bool baseRawsockTxSetMark(void *rawsock, int prio) { return false; } +U8 *baseRawsockGetTxFrame(void *rawsock, bool blocking, U32 *size) { return NULL; } +bool baseRawsockRelTxFrame(void *rawsock, U8 *pBuffer) { return false; } +bool baseRawsockTxFrameReady(void *rawsock, U8 *pFrame, U32 len) { return false; } +int baseRawsockSend(void *rawsock) { return -1; } +int baseRawsockTxBufLevel(void *rawsock) { return -1; } +int baseRawsockRxBufLevel(void *rawsock) { return -1; } +unsigned long baseRawsockGetTXOutOfBuffers(void *pvRawsock) { return 0; } +unsigned long baseRawsockGetTXOutOfBuffersCyclic(void *pvRawsock) { return 0; } + +void* baseRawsockOpen(base_rawsock_t* rawsock, const char *ifname, bool rx_mode, bool tx_mode, U16 ethertype, U32 frame_size, U32 num_frames) +{ + AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); + + rawsock->rxMode = rx_mode; + rawsock->txMode = tx_mode; + rawsock->frameSize = frame_size; + rawsock->ethertype = ethertype; + + // fill virtual functions table + rawsock_cb_t *cb = &rawsock->cb; + cb->setRxSignalMode = baseRawsockSetRxSignalMode; + cb->close = baseRawsockClose; + cb->getSocket = baseRawsockGetSocket; + cb->getAddr = baseRawsockGetAddr; + cb->getRxFrame = baseRawsockGetRxFrame; + cb->rxParseHdr = baseRawsockRxParseHdr; + cb->relRxFrame = baseRawsockRelRxFrame; + cb->rxMulticast = baseRawsockRxMulticast; + cb->rxAVTPSubtype = baseRawsockRxAVTPSubtype; + cb->txSetHdr = baseRawsockTxSetHdr; + cb->txFillHdr = baseRawsockTxFillHdr; + cb->txSetMark = baseRawsockTxSetMark; + cb->getTxFrame = baseRawsockGetTxFrame; + cb->relTxFrame = baseRawsockRelTxFrame; + cb->txFrameReady = baseRawsockTxFrameReady; + cb->send = baseRawsockSend; + cb->txBufLevel = baseRawsockTxBufLevel; + cb->rxBufLevel = baseRawsockRxBufLevel; + cb->getTXOutOfBuffers = baseRawsockGetTXOutOfBuffers; + cb->getTXOutOfBuffersCyclic = baseRawsockGetTXOutOfBuffersCyclic; + + + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); + return rawsock; +} + +void baseRawsockClose(void *rawsock) +{ + AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); + // free the state struct + free(rawsock); + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); +} + // Pre-set the ethernet header information that will be used on TX frames bool baseRawsockTxSetHdr(void *pvRawsock, hdr_info_t *pHdr) { @@ -120,15 +181,35 @@ bool baseRawsockGetAddr(void *pvRawsock, U8 addr[ETH_ALEN]) return TRUE; } +// Parse the ethernet frame header. Returns length of header, or -1 for failure +int baseRawsockRxParseHdr(void *pvRawsock, U8 *pBuffer, hdr_info_t *pInfo) +{ + AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); + + eth_hdr_t *eth_hdr = (eth_hdr_t*)pBuffer; + pInfo->dhost = eth_hdr->dhost; + pInfo->shost = eth_hdr->shost; + pInfo->ethertype = ntohs(eth_hdr->ethertype); + int hdrLen = sizeof(eth_hdr_t); + + if (pInfo->ethertype == ETHERTYPE_8021Q) { + pInfo->vlan = TRUE; + // TODO extract vlan_vid and vlan_pcp + hdrLen += 4; + } + + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); + return hdrLen; +} + + ///////////////////////////////////////////////////////////////////////////// void openavbSetRxSignalMode(void *pvRawsock, bool rxSignalMode) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.setRxSignalMode) - rawsock->cb.setRxSignalMode(pvRawsock, rxSignalMode); + ((base_rawsock_t*)pvRawsock)->cb.setRxSignalMode(pvRawsock, rxSignalMode); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); } @@ -137,9 +218,7 @@ void openavbRawsockClose(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.close) - rawsock->cb.close(pvRawsock); + ((base_rawsock_t*)pvRawsock)->cb.close(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); } @@ -147,11 +226,8 @@ void openavbRawsockClose(void *pvRawsock) U8 *openavbRawsockGetTxFrame(void *pvRawsock, bool blocking, unsigned int *len) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - U8 *ret = NULL; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.getTxFrame) - ret = rawsock->cb.getTxFrame(pvRawsock, blocking, len); + U8 *ret = ((base_rawsock_t*)pvRawsock)->cb.getTxFrame(pvRawsock, blocking, len); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -160,11 +236,8 @@ U8 *openavbRawsockGetTxFrame(void *pvRawsock, bool blocking, unsigned int *len) bool openavbRawsockTxSetMark(void *pvRawsock, int mark) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.txSetMark) - ret = rawsock->cb.txSetMark(pvRawsock, mark); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.txSetMark(pvRawsock, mark); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return ret; @@ -173,13 +246,8 @@ bool openavbRawsockTxSetMark(void *pvRawsock, int mark) bool openavbRawsockTxSetHdr(void *pvRawsock, hdr_info_t *pHdr) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.txSetHdr) - ret = rawsock->cb.txSetHdr(pvRawsock, pHdr); - else - ret = baseRawsockTxSetHdr(pvRawsock, pHdr); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.txSetHdr(pvRawsock, pHdr); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return ret; @@ -188,13 +256,8 @@ bool openavbRawsockTxSetHdr(void *pvRawsock, hdr_info_t *pHdr) bool openavbRawsockTxFillHdr(void *pvRawsock, U8 *pBuffer, unsigned int *hdrlen) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.txFillHdr) - ret = rawsock->cb.txFillHdr(pvRawsock, pBuffer, hdrlen); - else - ret = baseRawsockTxFillHdr(pvRawsock, pBuffer, hdrlen); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.txFillHdr(pvRawsock, pBuffer, hdrlen); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -203,11 +266,8 @@ bool openavbRawsockTxFillHdr(void *pvRawsock, U8 *pBuffer, unsigned int *hdrlen) bool openavbRawsockRelTxFrame(void *pvRawsock, U8 *pBuffer) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.relTxFrame) - ret = rawsock->cb.relTxFrame(pvRawsock, pBuffer); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.relTxFrame(pvRawsock, pBuffer); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -216,11 +276,8 @@ bool openavbRawsockRelTxFrame(void *pvRawsock, U8 *pBuffer) bool openavbRawsockTxFrameReady(void *pvRawsock, U8 *pBuffer, unsigned int len) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.txFrameReady) - ret = rawsock->cb.txFrameReady(pvRawsock, pBuffer, len); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.txFrameReady(pvRawsock, pBuffer, len); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -229,11 +286,8 @@ bool openavbRawsockTxFrameReady(void *pvRawsock, U8 *pBuffer, unsigned int len) int openavbRawsockSend(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - int ret = -1; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.send) - ret = rawsock->cb.send(pvRawsock); + int ret = ((base_rawsock_t*)pvRawsock)->cb.send(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -242,11 +296,8 @@ int openavbRawsockSend(void *pvRawsock) int openavbRawsockTxBufLevel(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - int ret = -1; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.txBufLevel) - ret = rawsock->cb.txBufLevel(pvRawsock); + int ret = ((base_rawsock_t*)pvRawsock)->cb.txBufLevel(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -255,11 +306,8 @@ int openavbRawsockTxBufLevel(void *pvRawsock) int openavbRawsockRxBufLevel(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - int ret = -1; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.rxBufLevel) - ret = rawsock->cb.rxBufLevel(pvRawsock); + int ret = ((base_rawsock_t*)pvRawsock)->cb.rxBufLevel(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -268,39 +316,28 @@ int openavbRawsockRxBufLevel(void *pvRawsock) U8 *openavbRawsockGetRxFrame(void *pvRawsock, U32 timeout, unsigned int *offset, unsigned int *len) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - U8 *ret = NULL; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.getRxFrame) - ret = rawsock->cb.getRxFrame(pvRawsock, timeout, offset, len); + U8 *ret = ((base_rawsock_t*)pvRawsock)->cb.getRxFrame(pvRawsock, timeout, offset, len); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; } -// Parse the ethernet frame header. Returns length of header, or -1 for failure int openavbRawsockRxParseHdr(void *pvRawsock, U8 *pBuffer, hdr_info_t *pInfo) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - int ret = -1; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.rxParseHdr) - ret = rawsock->cb.rxParseHdr(pvRawsock, pBuffer, pInfo); + int ret = ((base_rawsock_t*)pvRawsock)->cb.rxParseHdr(pvRawsock, pBuffer, pInfo); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; } -// Release a RX frame held by the client bool openavbRawsockRelRxFrame(void *pvRawsock, U8 *pBuffer) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.relRxFrame) - ret = rawsock->cb.relRxFrame(pvRawsock, pBuffer); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.relRxFrame(pvRawsock, pBuffer); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -309,11 +346,18 @@ bool openavbRawsockRelRxFrame(void *pvRawsock, U8 *pBuffer) bool openavbRawsockRxMulticast(void *pvRawsock, bool add_membership, const U8 addr[ETH_ALEN]) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.rxMulticast) - ret = rawsock->cb.rxMulticast(pvRawsock, add_membership, addr); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.rxMulticast(pvRawsock, add_membership, addr); + + AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); + return ret; +} + +bool openavbRawsockRxAVTPSubtype(void *pvRawsock, U8 subtype) +{ + AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); + + bool ret = ((base_rawsock_t*)pvRawsock)->cb.rxAVTPSubtype(pvRawsock, subtype); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return ret; @@ -322,11 +366,8 @@ bool openavbRawsockRxMulticast(void *pvRawsock, bool add_membership, const U8 ad int openavbRawsockGetSocket(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - int ret = -1; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.getSocket) - ret = rawsock->cb.getSocket(pvRawsock); + int ret = ((base_rawsock_t*)pvRawsock)->cb.getSocket(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return ret; @@ -335,13 +376,8 @@ int openavbRawsockGetSocket(void *pvRawsock) bool openavbRawsockGetAddr(void *pvRawsock, U8 addr[ETH_ALEN]) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK); - bool ret = false; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.getAddr) - ret = rawsock->cb.getAddr(pvRawsock, addr); - else - ret = baseRawsockGetAddr(pvRawsock, addr); + bool ret = ((base_rawsock_t*)pvRawsock)->cb.getAddr(pvRawsock, addr); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK); return ret; @@ -350,11 +386,8 @@ bool openavbRawsockGetAddr(void *pvRawsock, U8 addr[ETH_ALEN]) unsigned long openavbRawsockGetTXOutOfBuffers(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - unsigned long ret = 0; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.getTXOutOfBuffers) - ret = rawsock->cb.getTXOutOfBuffers(pvRawsock); + unsigned long ret = ((base_rawsock_t*)pvRawsock)->cb.getTXOutOfBuffers(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; @@ -363,11 +396,8 @@ unsigned long openavbRawsockGetTXOutOfBuffers(void *pvRawsock) unsigned long openavbRawsockGetTXOutOfBuffersCyclic(void *pvRawsock) { AVB_TRACE_ENTRY(AVB_TRACE_RAWSOCK_DETAIL); - unsigned long ret = 0; - base_rawsock_t *rawsock = (base_rawsock_t*)pvRawsock; - if (VALID_RAWSOCK(rawsock) && rawsock->cb.getTXOutOfBuffersCyclic) - ret = rawsock->cb.getTXOutOfBuffersCyclic(pvRawsock); + unsigned long ret = ((base_rawsock_t*)pvRawsock)->cb.getTXOutOfBuffersCyclic(pvRawsock); AVB_TRACE_EXIT(AVB_TRACE_RAWSOCK_DETAIL); return ret; diff --git a/lib/avtp_pipeline/rawsock/rawsock_impl.h b/lib/avtp_pipeline/rawsock/rawsock_impl.h index 3f207884..b1d6cf7b 100644 --- a/lib/avtp_pipeline/rawsock/rawsock_impl.h +++ b/lib/avtp_pipeline/rawsock/rawsock_impl.h @@ -36,6 +36,9 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175. // CORE TODO: This needs to be centralized; we have multiple defines for 0x8100 and some others like ETHERTYPE_AVTP #define ETHERTYPE_8021Q 0x8100 +#define VLAN_HLEN 4 // The additional bytes required by VLAN + // (in addition to the Ethernet header) + // Ethernet header typedef struct { U8 dhost[ETH_ALEN]; @@ -115,8 +118,11 @@ typedef struct base_rawsock { #define VALID_TX_RAWSOCK(s) (VALID_RAWSOCK(s) && ((base_rawsock_t*)s)->txMode) #define VALID_RX_RAWSOCK(s) (VALID_RAWSOCK(s) && ((base_rawsock_t*)s)->rxMode) +void* baseRawsockOpen(base_rawsock_t* rawsock, const char *ifname, bool rx_mode, bool tx_mode, U16 ethertype, U32 frame_size, U32 num_frames); +void baseRawsockClose(void* rawsock); bool baseRawsockTxSetHdr(void *pvRawsock, hdr_info_t *pHdr); bool baseRawsockTxFillHdr(void *pvRawsock, U8 *pBuffer, unsigned int *hdrlen); bool baseRawsockGetAddr(void *pvRawsock, U8 addr[ETH_ALEN]); +int baseRawsockRxParseHdr(void *pvRawsock, U8 *pBuffer, hdr_info_t *pInfo); #endif // RAWSOCK_IMPL_H diff --git a/lib/avtp_pipeline/tl/openavb_listener.c b/lib/avtp_pipeline/tl/openavb_listener.c index 506d327c..18333848 100644 --- a/lib/avtp_pipeline/tl/openavb_listener.c +++ b/lib/avtp_pipeline/tl/openavb_listener.c @@ -121,7 +121,7 @@ void listenerStopStream(tl_state_t *pTLState) openavbListenerAddStat(pTLState, TL_STAT_RX_LOST, openavbAvtpLost(pListenerData->avtpHandle)); openavbListenerAddStat(pTLState, TL_STAT_RX_BYTES, openavbAvtpBytes(pListenerData->avtpHandle)); - AVB_LOGF_INFO("RX "STREAMID_FORMAT", Totals: calls=%lld, frames=%lld, lost=%lld, bytes=%lld", + AVB_LOGF_INFO("RX "STREAMID_FORMAT", Totals: calls=%" PRIu64 "frames=%" PRIu64 "lost=%" PRIu64 "bytes=%" PRIu64, STREAMID_ARGS(&pListenerData->streamID), openavbListenerGetStat(pTLState, TL_STAT_RX_CALLS), openavbListenerGetStat(pTLState, TL_STAT_RX_FRAMES), diff --git a/lib/avtp_pipeline/tl/openavb_talker.c b/lib/avtp_pipeline/tl/openavb_talker.c index 73d6a406..8bc6ca42 100644 --- a/lib/avtp_pipeline/tl/openavb_talker.c +++ b/lib/avtp_pipeline/tl/openavb_talker.c @@ -104,8 +104,8 @@ bool talkerStartStream(tl_state_t *pTLState) U32 SRKbps = ((unsigned long)pTalkerData->classRate * (unsigned long)pCfg->max_interval_frames * (unsigned long)pStream->frameLen * 8L) / 1000; U32 DataKbps = ((unsigned long)pTalkerData->wakeRate * (unsigned long)pCfg->max_interval_frames * (unsigned long)pStream->frameLen * 8L) / 1000; - AVB_LOGF_INFO(STREAMID_FORMAT", sr-rate=%lu, data-rate=%lu, frames=%u, size=%u, batch=%u, sleep=%" PRId64 ", sr-Kbps=%d, data-Kbps=%d", - STREAMID_ARGS(&pTalkerData->streamID), (unsigned long)(pTalkerData->classRate), (unsigned long)(pTalkerData->wakeRate), + AVB_LOGF_INFO(STREAMID_FORMAT", sr-rate=%" PRIu32 ", data-rate=%lu, frames=%" PRIu16 ", size=%" PRIu16 ", batch=%" PRIu32 ", sleep=%" PRIu64 "us, sr-Kbps=%d, data-Kbps=%d", + STREAMID_ARGS(&pTalkerData->streamID), pTalkerData->classRate, pTalkerData->wakeRate, pTalkerData->tSpec.maxIntervalFrames, pTalkerData->tSpec.maxFrameSize, pCfg->batch_factor, pTalkerData->intervalNS / 1000, SRKbps, DataKbps); @@ -164,7 +164,7 @@ void talkerStopStream(tl_state_t *pTLState) // openavbTalkerAddStat(pTLState, TL_STAT_TX_LATE, 0); // Can't calulate at this time openavbTalkerAddStat(pTLState, TL_STAT_TX_BYTES, openavbAvtpBytes(pTalkerData->avtpHandle)); - AVB_LOGF_INFO("TX "STREAMID_FORMAT", Totals: calls=%lld, frames=%lld, late=%lld, bytes=%lld, TXOutOfBuffs=%ld", + AVB_LOGF_INFO("TX "STREAMID_FORMAT", Totals: calls=%" PRIu64 ", frames=%" PRIu64 ", late=%" PRIu64 ", bytes=%" PRIu64 ", TXOutOfBuffs=%ld", STREAMID_ARGS(&pTalkerData->streamID), openavbTalkerGetStat(pTLState, TL_STAT_TX_CALLS), openavbTalkerGetStat(pTLState, TL_STAT_TX_FRAMES), diff --git a/lib/avtp_pipeline/tl/openavb_talker_no_endpoint.c b/lib/avtp_pipeline/tl/openavb_talker_no_endpoint.c index 5d1aec64..d7e08225 100644 --- a/lib/avtp_pipeline/tl/openavb_talker_no_endpoint.c +++ b/lib/avtp_pipeline/tl/openavb_talker_no_endpoint.c @@ -74,12 +74,14 @@ bool openavbTLRunTalkerInit(tl_state_t *pTLState) pTalkerData->streamID.uniqueID = pCfg->stream_uid;
if (pCfg->sr_class == SR_CLASS_A) {
pTalkerData->classRate = 8000;
- pTalkerData->vlanID = SR_CLASS_A_DEFAULT_VID;
+ pTalkerData->vlanID = pCfg->vlan_id == VLAN_NULL ?
+ SR_CLASS_A_DEFAULT_VID : pCfg->vlan_id;
pTalkerData->vlanPCP = SR_CLASS_A_DEFAULT_PRIORITY;
}
else if (pCfg->sr_class == SR_CLASS_B) {
pTalkerData->classRate = 4000;
- pTalkerData->vlanID = SR_CLASS_B_DEFAULT_VID;
+ pTalkerData->vlanID = pCfg->vlan_id == VLAN_NULL ?
+ SR_CLASS_B_DEFAULT_VID : pCfg->vlan_id;
pTalkerData->vlanPCP = SR_CLASS_B_DEFAULT_PRIORITY;
}
memcpy(&pTalkerData->destAddr, &pCfg->dest_addr.mac->ether_addr_octet, ETH_ALEN);
diff --git a/lib/avtp_pipeline/tl/openavb_tl.c b/lib/avtp_pipeline/tl/openavb_tl.c index f22191a9..eb9ee145 100755 --- a/lib/avtp_pipeline/tl/openavb_tl.c +++ b/lib/avtp_pipeline/tl/openavb_tl.c @@ -395,6 +395,7 @@ EXTERN_DLL_EXPORT void openavbTLInitCfg(openavb_tl_cfg_t *pCfg) pCfg->rx_signal_mode = 1;
pCfg->pMapInitFn = NULL;
pCfg->pIntfInitFn = NULL;
+ pCfg->vlan_id = VLAN_NULL;
AVB_TRACE_EXIT(AVB_TRACE_TL);
}
diff --git a/lib/avtp_pipeline/tl/openavb_tl_pub.h b/lib/avtp_pipeline/tl/openavb_tl_pub.h index 58b59dfd..6e46494b 100755 --- a/lib/avtp_pipeline/tl/openavb_tl_pub.h +++ b/lib/avtp_pipeline/tl/openavb_tl_pub.h @@ -75,6 +75,9 @@ typedef enum { /// Maximum size of interface name #define IFNAMSIZE 16 +/// Indicatates that VLAN ID is not set in configuration +#define VLAN_NULL UINT16_MAX + /// Structure containing configuration of the host typedef struct { /// Role of the host @@ -122,6 +125,8 @@ typedef struct { bool tx_blocking_in_intf; /// Network interface name. Not used on all platforms. char ifname[IFNAMSIZE]; + /// VLAN ID + U16 vlan_id; /// When set incoming packets will trigger a signal to the stream task to wakeup. bool rx_signal_mode; |