0001
0002
0003
0004
0005
0006 #ifndef __DPAA2_ETH_H
0007 #define __DPAA2_ETH_H
0008
0009 #include <linux/dcbnl.h>
0010 #include <linux/netdevice.h>
0011 #include <linux/if_vlan.h>
0012 #include <linux/fsl/mc.h>
0013 #include <linux/net_tstamp.h>
0014 #include <net/devlink.h>
0015
0016 #include <soc/fsl/dpaa2-io.h>
0017 #include <soc/fsl/dpaa2-fd.h>
0018 #include "dpni.h"
0019 #include "dpni-cmd.h"
0020
0021 #include "dpaa2-eth-trace.h"
0022 #include "dpaa2-eth-debugfs.h"
0023 #include "dpaa2-mac.h"
0024
0025 #define DPAA2_WRIOP_VERSION(x, y, z) ((x) << 10 | (y) << 5 | (z) << 0)
0026
0027 #define DPAA2_ETH_STORE_SIZE 16
0028
0029
0030
0031
0032 #define DPAA2_ETH_MAX_SG_ENTRIES ((64 * 1024) / DPAA2_ETH_RX_BUF_SIZE)
0033
0034
0035
0036
0037 #define DPAA2_ETH_MFL (10 * 1024)
0038 #define DPAA2_ETH_MAX_MTU (DPAA2_ETH_MFL - VLAN_ETH_HLEN)
0039
0040 #define DPAA2_ETH_L2_MAX_FRM(mtu) ((mtu) + VLAN_ETH_HLEN)
0041
0042
0043
0044
0045
0046 #define DPAA2_ETH_FQ_TAILDROP_THRESH (1024 * 1024)
0047
0048
0049 #define DPAA2_ETH_MAX_BURST_SIZE 0xF7FF
0050
0051
0052
0053
0054 #define DPAA2_ETH_TXCONF_PER_NAPI 256
0055
0056
0057
0058
0059
0060
0061
0062 #define DPAA2_ETH_NUM_BUFS 1280
0063 #define DPAA2_ETH_REFILL_THRESH \
0064 (DPAA2_ETH_NUM_BUFS - DPAA2_ETH_BUFS_PER_CMD)
0065
0066
0067
0068
0069
0070
0071 #define DPAA2_ETH_CG_TAILDROP_THRESH(priv) \
0072 (1024 * dpaa2_eth_queue_count(priv) / dpaa2_eth_tc_count(priv))
0073
0074
0075
0076
0077
0078
0079
0080 #define DPAA2_ETH_CN_THRESH_ENTRY(priv) \
0081 (DPAA2_ETH_CG_TAILDROP_THRESH(priv) / 2)
0082 #define DPAA2_ETH_CN_THRESH_EXIT(priv) \
0083 (DPAA2_ETH_CN_THRESH_ENTRY(priv) * 3 / 4)
0084
0085
0086
0087
0088 #define DPAA2_ETH_BUFS_PER_CMD 7
0089
0090
0091 #define DPAA2_ETH_TX_BUF_ALIGN 64
0092
0093 #define DPAA2_ETH_RX_BUF_RAW_SIZE PAGE_SIZE
0094 #define DPAA2_ETH_RX_BUF_TAILROOM \
0095 SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
0096 #define DPAA2_ETH_RX_BUF_SIZE \
0097 (DPAA2_ETH_RX_BUF_RAW_SIZE - DPAA2_ETH_RX_BUF_TAILROOM)
0098
0099
0100 #define DPAA2_ETH_RX_HWA_SIZE 64
0101 #define DPAA2_ETH_TX_HWA_SIZE 128
0102
0103
0104 #define DPAA2_PTP_CLK_PERIOD_NS 1
0105
0106
0107
0108
0109 #define DPAA2_ETH_RX_BUF_ALIGN_REV1 256
0110 #define DPAA2_ETH_RX_BUF_ALIGN 64
0111
0112
0113
0114
0115
0116 #define DPAA2_ETH_SWA_SIZE 64
0117
0118
0119
0120
0121 enum dpaa2_eth_swa_type {
0122 DPAA2_ETH_SWA_SINGLE,
0123 DPAA2_ETH_SWA_SG,
0124 DPAA2_ETH_SWA_XDP,
0125 DPAA2_ETH_SWA_SW_TSO,
0126 };
0127
0128
0129 struct dpaa2_eth_swa {
0130 enum dpaa2_eth_swa_type type;
0131 union {
0132 struct {
0133 struct sk_buff *skb;
0134 int sgt_size;
0135 } single;
0136 struct {
0137 struct sk_buff *skb;
0138 struct scatterlist *scl;
0139 int num_sg;
0140 int sgt_size;
0141 } sg;
0142 struct {
0143 int dma_size;
0144 struct xdp_frame *xdpf;
0145 } xdp;
0146 struct {
0147 struct sk_buff *skb;
0148 int num_sg;
0149 int sgt_size;
0150 int is_last_fd;
0151 } tso;
0152 };
0153 };
0154
0155
0156 #define DPAA2_FD_FRC_FASV 0x8000
0157 #define DPAA2_FD_FRC_FAEADV 0x4000
0158 #define DPAA2_FD_FRC_FAPRV 0x2000
0159 #define DPAA2_FD_FRC_FAIADV 0x1000
0160 #define DPAA2_FD_FRC_FASWOV 0x0800
0161 #define DPAA2_FD_FRC_FAICFDV 0x0400
0162
0163
0164 #define DPAA2_FD_RX_ERR_MASK (FD_CTRL_SBE | FD_CTRL_FAERR)
0165 #define DPAA2_FD_TX_ERR_MASK (FD_CTRL_UFD | \
0166 FD_CTRL_SBE | \
0167 FD_CTRL_FSE | \
0168 FD_CTRL_FAERR)
0169
0170
0171 #define DPAA2_FD_CTRL_ASAL 0x00020000
0172
0173
0174 struct dpaa2_fas {
0175 u8 reserved;
0176 u8 ppid;
0177 __le16 ifpid;
0178 __le32 status;
0179 };
0180
0181
0182
0183
0184 #define DPAA2_FAS_OFFSET 0
0185 #define DPAA2_FAS_SIZE (sizeof(struct dpaa2_fas))
0186
0187
0188
0189
0190 #define DPAA2_TS_OFFSET 0x8
0191
0192
0193 struct dpaa2_fapr {
0194
0195 __le32 faf_lo;
0196 __le16 faf_ext;
0197 __le16 nxt_hdr;
0198
0199 __le64 faf_hi;
0200
0201 u8 last_ethertype_offset;
0202 u8 vlan_tci_offset_n;
0203 u8 vlan_tci_offset_1;
0204 u8 llc_snap_offset;
0205 u8 eth_offset;
0206 u8 ip1_pid_offset;
0207 u8 shim_offset_2;
0208 u8 shim_offset_1;
0209
0210 u8 l5_offset;
0211 u8 l4_offset;
0212 u8 gre_offset;
0213 u8 l3_offset_n;
0214 u8 l3_offset_1;
0215 u8 mpls_offset_n;
0216 u8 mpls_offset_1;
0217 u8 pppoe_offset;
0218
0219 __le16 running_sum;
0220 __le16 gross_running_sum;
0221 u8 ipv6_frag_offset;
0222 u8 nxt_hdr_offset;
0223 u8 routing_hdr_offset_2;
0224 u8 routing_hdr_offset_1;
0225
0226 u8 reserved[5];
0227 u8 ip_proto_offset_n;
0228 u8 nxt_hdr_frag_offset;
0229 u8 parse_error_code;
0230 };
0231
0232 #define DPAA2_FAPR_OFFSET 0x10
0233 #define DPAA2_FAPR_SIZE sizeof((struct dpaa2_fapr))
0234
0235
0236 #define DPAA2_FAEAD_OFFSET 0x58
0237
0238 struct dpaa2_faead {
0239 __le32 conf_fqid;
0240 __le32 ctrl;
0241 };
0242
0243 #define DPAA2_FAEAD_A2V 0x20000000
0244 #define DPAA2_FAEAD_A4V 0x08000000
0245 #define DPAA2_FAEAD_UPDV 0x00001000
0246 #define DPAA2_FAEAD_EBDDV 0x00002000
0247 #define DPAA2_FAEAD_UPD 0x00000010
0248
0249 struct ptp_tstamp {
0250 u16 sec_msb;
0251 u32 sec_lsb;
0252 u32 nsec;
0253 };
0254
0255 static inline void ns_to_ptp_tstamp(struct ptp_tstamp *tstamp, u64 ns)
0256 {
0257 u64 sec, nsec;
0258
0259 sec = ns;
0260 nsec = do_div(sec, 1000000000);
0261
0262 tstamp->sec_lsb = sec & 0xFFFFFFFF;
0263 tstamp->sec_msb = (sec >> 32) & 0xFFFF;
0264 tstamp->nsec = nsec;
0265 }
0266
0267
0268 static inline void *dpaa2_get_hwa(void *buf_addr, bool swa)
0269 {
0270 return buf_addr + (swa ? DPAA2_ETH_SWA_SIZE : 0);
0271 }
0272
0273 static inline struct dpaa2_fas *dpaa2_get_fas(void *buf_addr, bool swa)
0274 {
0275 return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAS_OFFSET;
0276 }
0277
0278 static inline __le64 *dpaa2_get_ts(void *buf_addr, bool swa)
0279 {
0280 return dpaa2_get_hwa(buf_addr, swa) + DPAA2_TS_OFFSET;
0281 }
0282
0283 static inline struct dpaa2_fapr *dpaa2_get_fapr(void *buf_addr, bool swa)
0284 {
0285 return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAPR_OFFSET;
0286 }
0287
0288 static inline struct dpaa2_faead *dpaa2_get_faead(void *buf_addr, bool swa)
0289 {
0290 return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAEAD_OFFSET;
0291 }
0292
0293
0294
0295 #define DPAA2_FAS_DISC 0x80000000
0296
0297 #define DPAA2_FAS_MS 0x40000000
0298 #define DPAA2_FAS_PTP 0x08000000
0299
0300 #define DPAA2_FAS_MC 0x04000000
0301
0302 #define DPAA2_FAS_BC 0x02000000
0303 #define DPAA2_FAS_KSE 0x00040000
0304 #define DPAA2_FAS_EOFHE 0x00020000
0305 #define DPAA2_FAS_MNLE 0x00010000
0306 #define DPAA2_FAS_TIDE 0x00008000
0307 #define DPAA2_FAS_PIEE 0x00004000
0308
0309 #define DPAA2_FAS_FLE 0x00002000
0310
0311 #define DPAA2_FAS_FPE 0x00001000
0312 #define DPAA2_FAS_PTE 0x00000080
0313 #define DPAA2_FAS_ISP 0x00000040
0314 #define DPAA2_FAS_PHE 0x00000020
0315 #define DPAA2_FAS_BLE 0x00000010
0316
0317 #define DPAA2_FAS_L3CV 0x00000008
0318
0319 #define DPAA2_FAS_L3CE 0x00000004
0320
0321 #define DPAA2_FAS_L4CV 0x00000002
0322
0323 #define DPAA2_FAS_L4CE 0x00000001
0324
0325 #define DPAA2_FAS_RX_ERR_MASK (DPAA2_FAS_KSE | \
0326 DPAA2_FAS_EOFHE | \
0327 DPAA2_FAS_MNLE | \
0328 DPAA2_FAS_TIDE | \
0329 DPAA2_FAS_PIEE | \
0330 DPAA2_FAS_FLE | \
0331 DPAA2_FAS_FPE | \
0332 DPAA2_FAS_PTE | \
0333 DPAA2_FAS_ISP | \
0334 DPAA2_FAS_PHE | \
0335 DPAA2_FAS_BLE | \
0336 DPAA2_FAS_L3CE | \
0337 DPAA2_FAS_L4CE)
0338
0339
0340 #define DPAA2_ETH_LINK_STATE_REFRESH 1000
0341
0342
0343
0344
0345
0346 #define DPAA2_ETH_ENQUEUE_RETRIES 10
0347
0348
0349
0350
0351
0352
0353
0354 #define DPAA2_ETH_SWP_BUSY_RETRIES 1000
0355
0356
0357
0358
0359 struct dpaa2_eth_drv_stats {
0360 __u64 tx_conf_frames;
0361 __u64 tx_conf_bytes;
0362 __u64 tx_sg_frames;
0363 __u64 tx_sg_bytes;
0364 __u64 tx_tso_frames;
0365 __u64 tx_tso_bytes;
0366 __u64 rx_sg_frames;
0367 __u64 rx_sg_bytes;
0368
0369 __u64 tx_converted_sg_frames;
0370 __u64 tx_converted_sg_bytes;
0371
0372 __u64 tx_portal_busy;
0373 };
0374
0375
0376 struct dpaa2_eth_fq_stats {
0377
0378 __u64 frames;
0379 };
0380
0381
0382 struct dpaa2_eth_ch_stats {
0383
0384 __u64 dequeue_portal_busy;
0385
0386 __u64 pull_err;
0387
0388 __u64 cdan;
0389
0390 __u64 xdp_drop;
0391 __u64 xdp_tx;
0392 __u64 xdp_tx_err;
0393 __u64 xdp_redirect;
0394
0395 __u64 frames;
0396 __u64 frames_per_cdan;
0397 __u64 bytes_per_cdan;
0398 };
0399
0400 #define DPAA2_ETH_CH_STATS 7
0401
0402
0403 #define DPAA2_ETH_MAX_TCS 8
0404 #define DPAA2_ETH_MAX_RX_QUEUES_PER_TC 16
0405 #define DPAA2_ETH_MAX_RX_QUEUES \
0406 (DPAA2_ETH_MAX_RX_QUEUES_PER_TC * DPAA2_ETH_MAX_TCS)
0407 #define DPAA2_ETH_MAX_TX_QUEUES 16
0408 #define DPAA2_ETH_MAX_RX_ERR_QUEUES 1
0409 #define DPAA2_ETH_MAX_QUEUES (DPAA2_ETH_MAX_RX_QUEUES + \
0410 DPAA2_ETH_MAX_TX_QUEUES + \
0411 DPAA2_ETH_MAX_RX_ERR_QUEUES)
0412 #define DPAA2_ETH_MAX_NETDEV_QUEUES \
0413 (DPAA2_ETH_MAX_TX_QUEUES * DPAA2_ETH_MAX_TCS)
0414
0415 #define DPAA2_ETH_MAX_DPCONS 16
0416
0417 enum dpaa2_eth_fq_type {
0418 DPAA2_RX_FQ = 0,
0419 DPAA2_TX_CONF_FQ,
0420 DPAA2_RX_ERR_FQ
0421 };
0422
0423 struct dpaa2_eth_priv;
0424
0425 struct dpaa2_eth_xdp_fds {
0426 struct dpaa2_fd fds[DEV_MAP_BULK_SIZE];
0427 ssize_t num;
0428 };
0429
0430 struct dpaa2_eth_fq {
0431 u32 fqid;
0432 u32 tx_qdbin;
0433 u32 tx_fqid[DPAA2_ETH_MAX_TCS];
0434 u16 flowid;
0435 u8 tc;
0436 int target_cpu;
0437 u32 dq_frames;
0438 u32 dq_bytes;
0439 struct dpaa2_eth_channel *channel;
0440 enum dpaa2_eth_fq_type type;
0441
0442 void (*consume)(struct dpaa2_eth_priv *priv,
0443 struct dpaa2_eth_channel *ch,
0444 const struct dpaa2_fd *fd,
0445 struct dpaa2_eth_fq *fq);
0446 struct dpaa2_eth_fq_stats stats;
0447
0448 struct dpaa2_eth_xdp_fds xdp_redirect_fds;
0449 struct dpaa2_eth_xdp_fds xdp_tx_fds;
0450 };
0451
0452 struct dpaa2_eth_ch_xdp {
0453 struct bpf_prog *prog;
0454 unsigned int res;
0455 };
0456
0457 struct dpaa2_eth_channel {
0458 struct dpaa2_io_notification_ctx nctx;
0459 struct fsl_mc_device *dpcon;
0460 int dpcon_id;
0461 int ch_id;
0462 struct napi_struct napi;
0463 struct dpaa2_io *dpio;
0464 struct dpaa2_io_store *store;
0465 struct dpaa2_eth_priv *priv;
0466 int buf_count;
0467 struct dpaa2_eth_ch_stats stats;
0468 struct dpaa2_eth_ch_xdp xdp;
0469 struct xdp_rxq_info xdp_rxq;
0470 struct list_head *rx_list;
0471
0472
0473 u64 recycled_bufs[DPAA2_ETH_BUFS_PER_CMD];
0474 int recycled_bufs_cnt;
0475 };
0476
0477 struct dpaa2_eth_dist_fields {
0478 u64 rxnfc_field;
0479 enum net_prot cls_prot;
0480 int cls_field;
0481 int size;
0482 u64 id;
0483 };
0484
0485 struct dpaa2_eth_cls_rule {
0486 struct ethtool_rx_flow_spec fs;
0487 u8 in_use;
0488 };
0489
0490 #define DPAA2_ETH_SGT_CACHE_SIZE 256
0491 struct dpaa2_eth_sgt_cache {
0492 void *buf[DPAA2_ETH_SGT_CACHE_SIZE];
0493 u16 count;
0494 };
0495
0496 struct dpaa2_eth_trap_item {
0497 void *trap_ctx;
0498 };
0499
0500 struct dpaa2_eth_trap_data {
0501 struct dpaa2_eth_trap_item *trap_items_arr;
0502 struct dpaa2_eth_priv *priv;
0503 };
0504
0505 #define DPAA2_ETH_SG_ENTRIES_MAX (PAGE_SIZE / sizeof(struct scatterlist))
0506
0507 #define DPAA2_ETH_DEFAULT_COPYBREAK 512
0508
0509 #define DPAA2_ETH_ENQUEUE_MAX_FDS 200
0510 struct dpaa2_eth_fds {
0511 struct dpaa2_fd array[DPAA2_ETH_ENQUEUE_MAX_FDS];
0512 };
0513
0514
0515 struct dpaa2_eth_priv {
0516 struct net_device *net_dev;
0517
0518 u8 num_fqs;
0519 struct dpaa2_eth_fq fq[DPAA2_ETH_MAX_QUEUES];
0520 int (*enqueue)(struct dpaa2_eth_priv *priv,
0521 struct dpaa2_eth_fq *fq,
0522 struct dpaa2_fd *fd, u8 prio,
0523 u32 num_frames,
0524 int *frames_enqueued);
0525
0526 u8 num_channels;
0527 struct dpaa2_eth_channel *channel[DPAA2_ETH_MAX_DPCONS];
0528 struct dpaa2_eth_sgt_cache __percpu *sgt_cache;
0529 unsigned long features;
0530 struct dpni_attr dpni_attrs;
0531 u16 dpni_ver_major;
0532 u16 dpni_ver_minor;
0533 u16 tx_data_offset;
0534 void __iomem *onestep_reg_base;
0535 u8 ptp_correction_off;
0536 void (*dpaa2_set_onestep_params_cb)(struct dpaa2_eth_priv *priv,
0537 u32 offset, u8 udp);
0538 struct fsl_mc_device *dpbp_dev;
0539 u16 rx_buf_size;
0540 u16 bpid;
0541 struct iommu_domain *iommu_domain;
0542
0543 enum hwtstamp_tx_types tx_tstamp_type;
0544 bool rx_tstamp;
0545
0546 u16 tx_qdid;
0547 struct fsl_mc_io *mc_io;
0548
0549
0550
0551 struct cpumask dpio_cpumask;
0552
0553
0554 struct rtnl_link_stats64 __percpu *percpu_stats;
0555
0556 struct dpaa2_eth_drv_stats __percpu *percpu_extras;
0557
0558 u16 mc_token;
0559 u8 rx_fqtd_enabled;
0560 u8 rx_cgtd_enabled;
0561
0562 struct dpni_link_state link_state;
0563 bool do_link_poll;
0564 struct task_struct *poll_thread;
0565
0566
0567 u64 rx_hash_fields;
0568 u64 rx_cls_fields;
0569 struct dpaa2_eth_cls_rule *cls_rules;
0570 u8 rx_cls_enabled;
0571 u8 vlan_cls_enabled;
0572 u8 pfc_enabled;
0573 #ifdef CONFIG_FSL_DPAA2_ETH_DCB
0574 u8 dcbx_mode;
0575 struct ieee_pfc pfc;
0576 #endif
0577 struct bpf_prog *xdp_prog;
0578 #ifdef CONFIG_DEBUG_FS
0579 struct dpaa2_debugfs dbg;
0580 #endif
0581
0582 struct dpaa2_mac *mac;
0583 struct workqueue_struct *dpaa2_ptp_wq;
0584 struct work_struct tx_onestep_tstamp;
0585 struct sk_buff_head tx_skbs;
0586
0587
0588
0589
0590
0591
0592
0593 struct mutex onestep_tstamp_lock;
0594 struct devlink *devlink;
0595 struct dpaa2_eth_trap_data *trap_data;
0596 struct devlink_port devlink_port;
0597
0598 u32 rx_copybreak;
0599
0600 struct dpaa2_eth_fds __percpu *fd;
0601 };
0602
0603 struct dpaa2_eth_devlink_priv {
0604 struct dpaa2_eth_priv *dpaa2_priv;
0605 };
0606
0607 #define TX_TSTAMP 0x1
0608 #define TX_TSTAMP_ONESTEP_SYNC 0x2
0609
0610 #define DPAA2_RXH_SUPPORTED (RXH_L2DA | RXH_VLAN | RXH_L3_PROTO \
0611 | RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 \
0612 | RXH_L4_B_2_3)
0613
0614
0615 #define DPAA2_RXH_DEFAULT (RXH_L3_PROTO | RXH_IP_SRC | RXH_IP_DST | \
0616 RXH_L4_B_0_1 | RXH_L4_B_2_3)
0617
0618 #define dpaa2_eth_hash_enabled(priv) \
0619 ((priv)->dpni_attrs.num_queues > 1)
0620
0621
0622 #define DPAA2_CLASSIFIER_DMA_SIZE 256
0623
0624 extern const struct ethtool_ops dpaa2_ethtool_ops;
0625 extern int dpaa2_phc_index;
0626 extern struct ptp_qoriq *dpaa2_ptp;
0627
0628 static inline int dpaa2_eth_cmp_dpni_ver(struct dpaa2_eth_priv *priv,
0629 u16 ver_major, u16 ver_minor)
0630 {
0631 if (priv->dpni_ver_major == ver_major)
0632 return priv->dpni_ver_minor - ver_minor;
0633 return priv->dpni_ver_major - ver_major;
0634 }
0635
0636
0637
0638
0639 #define DPNI_RX_DIST_KEY_VER_MAJOR 7
0640 #define DPNI_RX_DIST_KEY_VER_MINOR 5
0641
0642 #define dpaa2_eth_has_legacy_dist(priv) \
0643 (dpaa2_eth_cmp_dpni_ver((priv), DPNI_RX_DIST_KEY_VER_MAJOR, \
0644 DPNI_RX_DIST_KEY_VER_MINOR) < 0)
0645
0646 #define dpaa2_eth_fs_enabled(priv) \
0647 (!((priv)->dpni_attrs.options & DPNI_OPT_NO_FS))
0648
0649 #define dpaa2_eth_fs_mask_enabled(priv) \
0650 ((priv)->dpni_attrs.options & DPNI_OPT_HAS_KEY_MASKING)
0651
0652 #define dpaa2_eth_fs_count(priv) \
0653 ((priv)->dpni_attrs.fs_entries)
0654
0655 #define dpaa2_eth_tc_count(priv) \
0656 ((priv)->dpni_attrs.num_tcs)
0657
0658
0659 #define dpaa2_eth_queue_count(priv) \
0660 ((priv)->num_channels)
0661
0662 enum dpaa2_eth_rx_dist {
0663 DPAA2_ETH_RX_DIST_HASH,
0664 DPAA2_ETH_RX_DIST_CLS
0665 };
0666
0667
0668 #define DPAA2_ETH_DIST_ETHDST BIT(0)
0669 #define DPAA2_ETH_DIST_ETHSRC BIT(1)
0670 #define DPAA2_ETH_DIST_ETHTYPE BIT(2)
0671 #define DPAA2_ETH_DIST_VLAN BIT(3)
0672 #define DPAA2_ETH_DIST_IPSRC BIT(4)
0673 #define DPAA2_ETH_DIST_IPDST BIT(5)
0674 #define DPAA2_ETH_DIST_IPPROTO BIT(6)
0675 #define DPAA2_ETH_DIST_L4SRC BIT(7)
0676 #define DPAA2_ETH_DIST_L4DST BIT(8)
0677 #define DPAA2_ETH_DIST_ALL (~0ULL)
0678
0679 #define DPNI_PTP_ONESTEP_VER_MAJOR 8
0680 #define DPNI_PTP_ONESTEP_VER_MINOR 2
0681 #define DPAA2_ETH_FEATURE_ONESTEP_CFG_DIRECT BIT(0)
0682 #define DPAA2_PTP_SINGLE_STEP_ENABLE BIT(31)
0683 #define DPAA2_PTP_SINGLE_STEP_CH BIT(7)
0684 #define DPAA2_PTP_SINGLE_CORRECTION_OFF(v) ((v) << 8)
0685
0686 #define DPNI_PAUSE_VER_MAJOR 7
0687 #define DPNI_PAUSE_VER_MINOR 13
0688 #define dpaa2_eth_has_pause_support(priv) \
0689 (dpaa2_eth_cmp_dpni_ver((priv), DPNI_PAUSE_VER_MAJOR, \
0690 DPNI_PAUSE_VER_MINOR) >= 0)
0691
0692 static inline bool dpaa2_eth_tx_pause_enabled(u64 link_options)
0693 {
0694 return !!(link_options & DPNI_LINK_OPT_PAUSE) ^
0695 !!(link_options & DPNI_LINK_OPT_ASYM_PAUSE);
0696 }
0697
0698 static inline bool dpaa2_eth_rx_pause_enabled(u64 link_options)
0699 {
0700 return !!(link_options & DPNI_LINK_OPT_PAUSE);
0701 }
0702
0703 static inline unsigned int dpaa2_eth_needed_headroom(struct sk_buff *skb)
0704 {
0705 unsigned int headroom = DPAA2_ETH_SWA_SIZE;
0706
0707
0708
0709
0710 if (!skb)
0711 return headroom;
0712
0713
0714
0715
0716 if (skb_is_nonlinear(skb))
0717 return 0;
0718
0719
0720 if (skb->cb[0])
0721 headroom += DPAA2_ETH_TX_HWA_SIZE;
0722
0723 return headroom;
0724 }
0725
0726
0727
0728
0729 static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
0730 {
0731 return priv->tx_data_offset - DPAA2_ETH_RX_HWA_SIZE;
0732 }
0733
0734 static inline bool dpaa2_eth_is_type_phy(struct dpaa2_eth_priv *priv)
0735 {
0736 if (priv->mac &&
0737 (priv->mac->attr.link_type == DPMAC_LINK_TYPE_PHY ||
0738 priv->mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE))
0739 return true;
0740
0741 return false;
0742 }
0743
0744 static inline bool dpaa2_eth_has_mac(struct dpaa2_eth_priv *priv)
0745 {
0746 return priv->mac ? true : false;
0747 }
0748
0749 int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags);
0750 int dpaa2_eth_set_cls(struct net_device *net_dev, u64 key);
0751 int dpaa2_eth_cls_key_size(u64 key);
0752 int dpaa2_eth_cls_fld_off(int prot, int field);
0753 void dpaa2_eth_cls_trim_rule(void *key_mem, u64 fields);
0754
0755 void dpaa2_eth_set_rx_taildrop(struct dpaa2_eth_priv *priv,
0756 bool tx_pause, bool pfc);
0757
0758 extern const struct dcbnl_rtnl_ops dpaa2_eth_dcbnl_ops;
0759
0760 int dpaa2_eth_dl_alloc(struct dpaa2_eth_priv *priv);
0761 void dpaa2_eth_dl_free(struct dpaa2_eth_priv *priv);
0762
0763 void dpaa2_eth_dl_register(struct dpaa2_eth_priv *priv);
0764 void dpaa2_eth_dl_unregister(struct dpaa2_eth_priv *priv);
0765
0766 int dpaa2_eth_dl_port_add(struct dpaa2_eth_priv *priv);
0767 void dpaa2_eth_dl_port_del(struct dpaa2_eth_priv *priv);
0768
0769 int dpaa2_eth_dl_traps_register(struct dpaa2_eth_priv *priv);
0770 void dpaa2_eth_dl_traps_unregister(struct dpaa2_eth_priv *priv);
0771
0772 struct dpaa2_eth_trap_item *dpaa2_eth_dl_get_trap(struct dpaa2_eth_priv *priv,
0773 struct dpaa2_fapr *fapr);
0774 #endif