aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/soc/fsl
diff options
context:
space:
mode:
authorRoy Pledge <roy.pledge@nxp.com>2018-12-18 10:23:01 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-19 13:37:22 -0500
commite80081c34b03587cf6e89c0a1ea16c71b40bccca (patch)
tree6e5a662589cd1cb03359ae22197e2b0a8cab4c05 /drivers/soc/fsl
parent7b98f63ea777d90abaca41beadf71e3f62d180e0 (diff)
soc: fsl: dpio: Add BP and FQ query APIs
Add FQ (Frame Queue) and BP (Buffer Pool) query APIs that users of QBMan can invoke to see the status of the queues and pools that they are using. Signed-off-by: Roy Pledge <roy.pledge@nxp.com> Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/soc/fsl')
-rw-r--r--drivers/soc/fsl/dpio/dpio-service.c68
-rw-r--r--drivers/soc/fsl/dpio/qbman-portal.c96
-rw-r--r--drivers/soc/fsl/dpio/qbman-portal.h58
3 files changed, 222 insertions, 0 deletions
diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
index 321a92613a7e..ec0837ff039a 100644
--- a/drivers/soc/fsl/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -601,3 +601,71 @@ struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last)
601 return ret; 601 return ret;
602} 602}
603EXPORT_SYMBOL_GPL(dpaa2_io_store_next); 603EXPORT_SYMBOL_GPL(dpaa2_io_store_next);
604
605/**
606 * dpaa2_io_query_fq_count() - Get the frame and byte count for a given fq.
607 * @d: the given DPIO object.
608 * @fqid: the id of frame queue to be queried.
609 * @fcnt: the queried frame count.
610 * @bcnt: the queried byte count.
611 *
612 * Knowing the FQ count at run-time can be useful in debugging situations.
613 * The instantaneous frame- and byte-count are hereby returned.
614 *
615 * Return 0 for a successful query, and negative error code if query fails.
616 */
617int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid,
618 u32 *fcnt, u32 *bcnt)
619{
620 struct qbman_fq_query_np_rslt state;
621 struct qbman_swp *swp;
622 unsigned long irqflags;
623 int ret;
624
625 d = service_select(d);
626 if (!d)
627 return -ENODEV;
628
629 swp = d->swp;
630 spin_lock_irqsave(&d->lock_mgmt_cmd, irqflags);
631 ret = qbman_fq_query_state(swp, fqid, &state);
632 spin_unlock_irqrestore(&d->lock_mgmt_cmd, irqflags);
633 if (ret)
634 return ret;
635 *fcnt = qbman_fq_state_frame_count(&state);
636 *bcnt = qbman_fq_state_byte_count(&state);
637
638 return 0;
639}
640EXPORT_SYMBOL_GPL(dpaa2_io_query_fq_count);
641
642/**
643 * dpaa2_io_query_bp_count() - Query the number of buffers currently in a
644 * buffer pool.
645 * @d: the given DPIO object.
646 * @bpid: the index of buffer pool to be queried.
647 * @num: the queried number of buffers in the buffer pool.
648 *
649 * Return 0 for a successful query, and negative error code if query fails.
650 */
651int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, u32 *num)
652{
653 struct qbman_bp_query_rslt state;
654 struct qbman_swp *swp;
655 unsigned long irqflags;
656 int ret;
657
658 d = service_select(d);
659 if (!d)
660 return -ENODEV;
661
662 swp = d->swp;
663 spin_lock_irqsave(&d->lock_mgmt_cmd, irqflags);
664 ret = qbman_bp_query(swp, bpid, &state);
665 spin_unlock_irqrestore(&d->lock_mgmt_cmd, irqflags);
666 if (ret)
667 return ret;
668 *num = qbman_bp_info_num_free_bufs(&state);
669 return 0;
670}
671EXPORT_SYMBOL_GPL(dpaa2_io_query_bp_count);
diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c
index cf1d448ea468..0bddb85c0ae5 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -1003,3 +1003,99 @@ int qbman_swp_CDAN_set(struct qbman_swp *s, u16 channelid,
1003 1003
1004 return 0; 1004 return 0;
1005} 1005}
1006
1007#define QBMAN_RESPONSE_VERB_MASK 0x7f
1008#define QBMAN_FQ_QUERY_NP 0x45
1009#define QBMAN_BP_QUERY 0x32
1010
1011struct qbman_fq_query_desc {
1012 u8 verb;
1013 u8 reserved[3];
1014 __le32 fqid;
1015 u8 reserved2[56];
1016};
1017
1018int qbman_fq_query_state(struct qbman_swp *s, u32 fqid,
1019 struct qbman_fq_query_np_rslt *r)
1020{
1021 struct qbman_fq_query_desc *p;
1022 void *resp;
1023
1024 p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s);
1025 if (!p)
1026 return -EBUSY;
1027
1028 /* FQID is a 24 bit value */
1029 p->fqid = cpu_to_le32(fqid & 0x00FFFFFF);
1030 resp = qbman_swp_mc_complete(s, p, QBMAN_FQ_QUERY_NP);
1031 if (!resp) {
1032 pr_err("qbman: Query FQID %d NP fields failed, no response\n",
1033 fqid);
1034 return -EIO;
1035 }
1036 *r = *(struct qbman_fq_query_np_rslt *)resp;
1037 /* Decode the outcome */
1038 WARN_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY_NP);
1039
1040 /* Determine success or failure */
1041 if (r->rslt != QBMAN_MC_RSLT_OK) {
1042 pr_err("Query NP fields of FQID 0x%x failed, code=0x%02x\n",
1043 p->fqid, r->rslt);
1044 return -EIO;
1045 }
1046
1047 return 0;
1048}
1049
1050u32 qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r)
1051{
1052 return (le32_to_cpu(r->frm_cnt) & 0x00FFFFFF);
1053}
1054
1055u32 qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r)
1056{
1057 return le32_to_cpu(r->byte_cnt);
1058}
1059
1060struct qbman_bp_query_desc {
1061 u8 verb;
1062 u8 reserved;
1063 __le16 bpid;
1064 u8 reserved2[60];
1065};
1066
1067int qbman_bp_query(struct qbman_swp *s, u16 bpid,
1068 struct qbman_bp_query_rslt *r)
1069{
1070 struct qbman_bp_query_desc *p;
1071 void *resp;
1072
1073 p = (struct qbman_bp_query_desc *)qbman_swp_mc_start(s);
1074 if (!p)
1075 return -EBUSY;
1076
1077 p->bpid = cpu_to_le16(bpid);
1078 resp = qbman_swp_mc_complete(s, p, QBMAN_BP_QUERY);
1079 if (!resp) {
1080 pr_err("qbman: Query BPID %d fields failed, no response\n",
1081 bpid);
1082 return -EIO;
1083 }
1084 *r = *(struct qbman_bp_query_rslt *)resp;
1085 /* Decode the outcome */
1086 WARN_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_BP_QUERY);
1087
1088 /* Determine success or failure */
1089 if (r->rslt != QBMAN_MC_RSLT_OK) {
1090 pr_err("Query fields of BPID 0x%x failed, code=0x%02x\n",
1091 bpid, r->rslt);
1092 return -EIO;
1093 }
1094
1095 return 0;
1096}
1097
1098u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a)
1099{
1100 return le32_to_cpu(a->fill);
1101}
diff --git a/drivers/soc/fsl/dpio/qbman-portal.h b/drivers/soc/fsl/dpio/qbman-portal.h
index 89d1dd9969b6..fa35fc1afeaa 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.h
+++ b/drivers/soc/fsl/dpio/qbman-portal.h
@@ -441,4 +441,62 @@ static inline void *qbman_swp_mc_complete(struct qbman_swp *swp, void *cmd,
441 return cmd; 441 return cmd;
442} 442}
443 443
444/* Query APIs */
445struct qbman_fq_query_np_rslt {
446 u8 verb;
447 u8 rslt;
448 u8 st1;
449 u8 st2;
450 u8 reserved[2];
451 __le16 od1_sfdr;
452 __le16 od2_sfdr;
453 __le16 od3_sfdr;
454 __le16 ra1_sfdr;
455 __le16 ra2_sfdr;
456 __le32 pfdr_hptr;
457 __le32 pfdr_tptr;
458 __le32 frm_cnt;
459 __le32 byte_cnt;
460 __le16 ics_surp;
461 u8 is;
462 u8 reserved2[29];
463};
464
465int qbman_fq_query_state(struct qbman_swp *s, u32 fqid,
466 struct qbman_fq_query_np_rslt *r);
467u32 qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r);
468u32 qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r);
469
470struct qbman_bp_query_rslt {
471 u8 verb;
472 u8 rslt;
473 u8 reserved[4];
474 u8 bdi;
475 u8 state;
476 __le32 fill;
477 __le32 hdotr;
478 __le16 swdet;
479 __le16 swdxt;
480 __le16 hwdet;
481 __le16 hwdxt;
482 __le16 swset;
483 __le16 swsxt;
484 __le16 vbpid;
485 __le16 icid;
486 __le64 bpscn_addr;
487 __le64 bpscn_ctx;
488 __le16 hw_targ;
489 u8 dbe;
490 u8 reserved2;
491 u8 sdcnt;
492 u8 hdcnt;
493 u8 sscnt;
494 u8 reserved3[9];
495};
496
497int qbman_bp_query(struct qbman_swp *s, u16 bpid,
498 struct qbman_bp_query_rslt *r);
499
500u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a);
501
444#endif /* __FSL_QBMAN_PORTAL_H */ 502#endif /* __FSL_QBMAN_PORTAL_H */