baseband/turbo_sw: allow to build without SDK dependency
authorNicolas Chautru <nicolas.chautru@intel.com>
Wed, 19 Jun 2019 17:48:36 +0000 (10:48 -0700)
committerAkhil Goyal <akhil.goyal@nxp.com>
Fri, 5 Jul 2019 13:28:14 +0000 (15:28 +0200)
Adding compile flag to allow to build the turbo_sw PMD
without dependency to have the SDK libraries installed.

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
Acked-by: Amr Mokhtar <amr.mokhtar@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
config/common_base
drivers/baseband/turbo_sw/Makefile
drivers/baseband/turbo_sw/bbdev_turbo_software.c
mk/rte.app.mk

index 0641c46..757f365 100644 (file)
@@ -539,6 +539,7 @@ CONFIG_RTE_PMD_PACKET_PREFETCH=y
 CONFIG_RTE_LIBRTE_BBDEV=y
 CONFIG_RTE_BBDEV_MAX_DEVS=128
 CONFIG_RTE_BBDEV_OFFLOAD_COST=y
+CONFIG_RTE_BBDEV_SDK_AVX2=n
 
 #
 # Compile PMD for NULL bbdev device
@@ -548,7 +549,7 @@ CONFIG_RTE_LIBRTE_PMD_BBDEV_NULL=y
 #
 # Compile PMD for turbo software bbdev device
 #
-CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW=n
+CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW=y
 
 #
 # Compile generic crypto device library
index d364677..414d0d9 100644 (file)
@@ -3,9 +3,6 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-ifeq ($(FLEXRAN_SDK),)
-$(error "Please define FLEXRAN_SDK environment variable")
-endif
 
 # library name
 LIB = librte_pmd_bbdev_turbo_sw.a
@@ -21,17 +18,21 @@ LDLIBS += -lrte_bus_vdev
 # versioning export map
 EXPORT_MAP := rte_pmd_bbdev_turbo_sw_version.map
 
-# external library dependencies
+# external library dependencies if available
+ifeq ($(CONFIG_RTE_BBDEV_SDK_AVX2),y)
+ifeq ($(FLEXRAN_SDK),)
+$(error "Please define FLEXRAN_SDK environment variable")
+endif
 CFLAGS += -I$(FLEXRAN_SDK)/lib_common
 CFLAGS += -I$(FLEXRAN_SDK)/lib_turbo
 CFLAGS += -I$(FLEXRAN_SDK)/lib_crc
 CFLAGS += -I$(FLEXRAN_SDK)/lib_rate_matching
-
 LDLIBS += -L$(FLEXRAN_SDK)/lib_turbo -lturbo
 LDLIBS += -L$(FLEXRAN_SDK)/lib_crc -lcrc
 LDLIBS += -L$(FLEXRAN_SDK)/lib_rate_matching -lrate_matching
 LDLIBS += -L$(FLEXRAN_SDK)/lib_common -lcommon
-LDLIBS += -lstdc++ -lirc -limf -lipps
+LDLIBS += -lstdc++ -lirc -limf -lipps -lsvml
+endif
 
 # library version
 LIBABIVER := 1
index 5204a77..94aa536 100644 (file)
 #include <rte_bbdev.h>
 #include <rte_bbdev_pmd.h>
 
+#ifdef RTE_BBDEV_SDK_AVX2
 #include <phy_turbo.h>
 #include <phy_crc.h>
 #include <phy_rate_match.h>
-#include <divide.h>
+#endif
 
 #define DRIVER_NAME baseband_turbo_sw
 
@@ -83,6 +84,7 @@ struct turbo_sw_queue {
        enum rte_bbdev_op_type type;
 } __rte_cache_aligned;
 
+#ifdef RTE_BBDEV_SDK_AVX2
 static inline char *
 mbuf_append(struct rte_mbuf *m_head, struct rte_mbuf *m, uint16_t len)
 {
@@ -128,6 +130,7 @@ compute_idx(uint16_t k)
 
        return result;
 }
+#endif
 
 /* Read flag value 0/1 from bitmap */
 static inline bool
@@ -143,6 +146,7 @@ info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
        struct bbdev_private *internals = dev->data->dev_private;
 
        static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
+#ifdef RTE_BBDEV_SDK_AVX2
                {
                        .type = RTE_BBDEV_OP_TURBO_DEC,
                        .cap.turbo_dec = {
@@ -172,6 +176,7 @@ info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
                                .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS,
                        }
                },
+#endif
                RTE_BBDEV_END_OF_CAPABILITIES_LIST()
        };
 
@@ -179,7 +184,12 @@ info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
                .queue_size = RTE_BBDEV_QUEUE_SIZE_LIMIT,
        };
 
+#ifdef RTE_BBDEV_SDK_AVX2
        static const enum rte_cpu_flag_t cpu_flag = RTE_CPUFLAG_SSE4_2;
+       dev_info->cpu_flag_reqs = &cpu_flag;
+#else
+       dev_info->cpu_flag_reqs = NULL;
+#endif
 
        default_queue_conf.socket = dev->data->socket_id;
 
@@ -191,7 +201,6 @@ info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
        dev_info->max_ul_queue_priority = 0;
        dev_info->default_queue_conf = default_queue_conf;
        dev_info->capabilities = bbdev_capabilities;
-       dev_info->cpu_flag_reqs = &cpu_flag;
        dev_info->min_alignment = 64;
 
        rte_bbdev_log_debug("got device info from %u\n", dev->data->dev_id);
@@ -410,6 +419,7 @@ static const struct rte_bbdev_ops pmd_ops = {
        .queue_release = q_release
 };
 
+#ifdef RTE_BBDEV_SDK_AVX2
 /* Checks if the encoder input buffer is correct.
  * Returns 0 if it's valid, -1 otherwise.
  */
@@ -464,6 +474,7 @@ is_dec_input_valid(int32_t k_idx, int16_t kw, int16_t in_length)
 
        return 0;
 }
+#endif
 
 static inline void
 process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
@@ -472,6 +483,7 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
                struct rte_mbuf *m_out, uint16_t in_offset, uint16_t out_offset,
                uint16_t in_length, struct rte_bbdev_stats *q_stats)
 {
+#ifdef RTE_BBDEV_SDK_AVX2
        int ret;
        int16_t k_idx;
        uint16_t m;
@@ -724,6 +736,22 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
                }
                *tmp_out = 0;
        }
+#else
+       RTE_SET_USED(q);
+       RTE_SET_USED(op);
+       RTE_SET_USED(r);
+       RTE_SET_USED(c);
+       RTE_SET_USED(k);
+       RTE_SET_USED(ncb);
+       RTE_SET_USED(e);
+       RTE_SET_USED(m_in);
+       RTE_SET_USED(m_out_head);
+       RTE_SET_USED(m_out);
+       RTE_SET_USED(in_offset);
+       RTE_SET_USED(out_offset);
+       RTE_SET_USED(in_length);
+       RTE_SET_USED(q_stats);
+#endif
 }
 
 static inline void
@@ -835,6 +863,7 @@ enqueue_enc_all_ops(struct turbo_sw_queue *q, struct rte_bbdev_enc_op **ops,
                        NULL);
 }
 
+#ifdef RTE_BBDEV_SDK_AVX2
 static inline void
 move_padding_bytes(const uint8_t *in, uint8_t *out, uint16_t k,
                uint16_t ncb)
@@ -847,6 +876,7 @@ move_padding_bytes(const uint8_t *in, uint8_t *out, uint16_t k,
        rte_memcpy(&out[nd + kpi + 64], &in[kpi], d);
        rte_memcpy(&out[(nd - 1) + 2 * (kpi + 64)], &in[2 * kpi], d);
 }
+#endif
 
 static inline void
 process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
@@ -856,6 +886,7 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
                uint16_t crc24_overlap, uint16_t in_length,
                struct rte_bbdev_stats *q_stats)
 {
+#ifdef RTE_BBDEV_SDK_AVX2
        int ret;
        int32_t k_idx;
        int32_t iter_cnt;
@@ -972,6 +1003,22 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
                rte_bbdev_log(ERR, "Turbo Decoder failed");
                return;
        }
+#else
+       RTE_SET_USED(q);
+       RTE_SET_USED(op);
+       RTE_SET_USED(c);
+       RTE_SET_USED(k);
+       RTE_SET_USED(kw);
+       RTE_SET_USED(m_in);
+       RTE_SET_USED(m_out_head);
+       RTE_SET_USED(m_out);
+       RTE_SET_USED(in_offset);
+       RTE_SET_USED(out_offset);
+       RTE_SET_USED(check_crc_24b);
+       RTE_SET_USED(crc24_overlap);
+       RTE_SET_USED(in_length);
+       RTE_SET_USED(q_stats);
+#endif
 }
 
 static inline void
index 4ec415e..5dcef13 100644 (file)
@@ -229,11 +229,14 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_NULL)     += -lrte_pmd_bbdev_null
 
 # TURBO SOFTWARE PMD is dependent on the FLEXRAN library
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW) += -lrte_pmd_bbdev_turbo_sw
+ifeq ($(CONFIG_RTE_BBDEV_SDK_AVX2),y)
+# Dependency on the FLEXRAN SDK library if available
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW) += -L$(FLEXRAN_SDK)/lib_crc -lcrc
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW) += -L$(FLEXRAN_SDK)/lib_turbo -lturbo
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW) += -L$(FLEXRAN_SDK)/lib_rate_matching -lrate_matching
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW) += -L$(FLEXRAN_SDK)/lib_common -lcommon
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BBDEV_TURBO_SW) += -lirc -limf -lstdc++ -lipps
+endif # CONFIG_RTE_BBDEV_SDK_AVX2
 endif # CONFIG_RTE_LIBRTE_BBDEV
 
 ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)