net/octeontx2: add remaining PTP operations
[dpdk.git] / drivers / net / octeontx2 / otx2_ethdev.h
index 5dd5d8c..8f8d93a 100644 (file)
@@ -13,6 +13,7 @@
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
+#include <rte_time.h>
 
 #include "otx2_common.h"
 #include "otx2_dev.h"
@@ -87,6 +88,9 @@
 #define NIX_TX_NB_SEG_MAX              9
 #endif
 
+/* Apply BP when CQ is 75% full */
+#define NIX_CQ_BP_LEVEL (25 * 256 / 100)
+
 #define CQ_OP_STAT_OP_ERR      63
 #define CQ_OP_STAT_CQ_ERR      46
 
 #define NIX_DEFAULT_RSS_CTX_GROUP  0
 #define NIX_DEFAULT_RSS_MCAM_IDX  -1
 
+#define otx2_ethdev_is_ptp_en(dev)     ((dev)->ptp_en)
+
+#define NIX_TIMESYNC_TX_CMD_LEN                8
+/* Additional timesync values. */
+#define OTX2_CYCLECOUNTER_MASK   0xffffffffffffffffULL
+
 enum nix_q_size_e {
        nix_q_size_16,  /* 16 entries */
        nix_q_size_64,  /* 64 entries */
@@ -169,6 +179,14 @@ struct otx2_npc_flow_info {
        uint16_t flow_max_priority;
 };
 
+struct otx2_fc_info {
+       enum rte_eth_fc_mode mode;  /**< Link flow control mode */
+       uint8_t rx_pause;
+       uint8_t tx_pause;
+       uint8_t chan_cnt;
+       uint16_t bpid[NIX_MAX_CHAN];
+};
+
 struct otx2_eth_dev {
        OTX2_DEV; /* Base class */
        MARKER otx2_eth_dev_data_start;
@@ -216,12 +234,19 @@ struct otx2_eth_dev {
        struct otx2_nix_tm_node_list node_list;
        struct otx2_nix_tm_shaper_profile_list shaper_profile_list;
        struct otx2_rss_info rss_info;
+       struct otx2_fc_info fc_info;
        uint32_t txmap[RTE_ETHDEV_QUEUE_STAT_CNTRS];
        uint32_t rxmap[RTE_ETHDEV_QUEUE_STAT_CNTRS];
        struct otx2_npc_flow_info npc_flow;
        struct otx2_eth_qconf *tx_qconf;
        struct otx2_eth_qconf *rx_qconf;
        struct rte_eth_dev *eth_dev;
+       /* PTP counters */
+       bool ptp_en;
+       struct otx2_timesync_info tstamp;
+       struct rte_timecounter  systime_tc;
+       struct rte_timecounter  rx_tstamp_tc;
+       struct rte_timecounter  tx_tstamp_tc;
 } __rte_cache_aligned;
 
 struct otx2_eth_txq {
@@ -368,6 +393,17 @@ int otx2_cgx_rxtx_stop(struct otx2_eth_dev *dev);
 int otx2_cgx_mac_addr_set(struct rte_eth_dev *eth_dev,
                          struct rte_ether_addr *addr);
 
+/* Flow Control */
+int otx2_nix_flow_ctrl_get(struct rte_eth_dev *eth_dev,
+                          struct rte_eth_fc_conf *fc_conf);
+
+int otx2_nix_flow_ctrl_set(struct rte_eth_dev *eth_dev,
+                          struct rte_eth_fc_conf *fc_conf);
+
+int otx2_nix_rxchan_bpid_cfg(struct rte_eth_dev *eth_dev, bool enb);
+
+int otx2_nix_update_flow_ctrl_mode(struct rte_eth_dev *eth_dev);
+
 /* Lookup configuration */
 void *otx2_nix_fastpath_lookup_mem_get(void);
 
@@ -391,4 +427,19 @@ int otx2_ethdev_parse_devargs(struct rte_devargs *devargs,
 /* Rx and Tx routines */
 void otx2_nix_form_default_desc(struct otx2_eth_txq *txq);
 
+/* Timesync - PTP routines */
+int otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev);
+int otx2_nix_timesync_disable(struct rte_eth_dev *eth_dev);
+int otx2_nix_timesync_read_rx_timestamp(struct rte_eth_dev *eth_dev,
+                                       struct timespec *timestamp,
+                                       uint32_t flags);
+int otx2_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
+                                       struct timespec *timestamp);
+int otx2_nix_timesync_adjust_time(struct rte_eth_dev *eth_dev, int64_t delta);
+int otx2_nix_timesync_write_time(struct rte_eth_dev *eth_dev,
+                                const struct timespec *ts);
+int otx2_nix_timesync_read_time(struct rte_eth_dev *eth_dev,
+                               struct timespec *ts);
+int otx2_eth_dev_ptp_info_update(struct otx2_dev *dev, bool ptp_en);
+
 #endif /* __OTX2_ETHDEV_H__ */