@@ -1003,3 +1003,99 @@ int qbman_swp_CDAN_set(struct qbman_swp *s, u16 channelid,
10031003
10041004 return 0 ;
10051005}
1006+
1007+ #define QBMAN_RESPONSE_VERB_MASK 0x7f
1008+ #define QBMAN_FQ_QUERY_NP 0x45
1009+ #define QBMAN_BP_QUERY 0x32
1010+
1011+ struct qbman_fq_query_desc {
1012+ u8 verb ;
1013+ u8 reserved [3 ];
1014+ __le32 fqid ;
1015+ u8 reserved2 [56 ];
1016+ };
1017+
1018+ int 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+
1050+ u32 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+
1055+ u32 qbman_fq_state_byte_count (const struct qbman_fq_query_np_rslt * r )
1056+ {
1057+ return le32_to_cpu (r -> byte_cnt );
1058+ }
1059+
1060+ struct qbman_bp_query_desc {
1061+ u8 verb ;
1062+ u8 reserved ;
1063+ __le16 bpid ;
1064+ u8 reserved2 [60 ];
1065+ };
1066+
1067+ int 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+
1098+ u32 qbman_bp_info_num_free_bufs (struct qbman_bp_query_rslt * a )
1099+ {
1100+ return le32_to_cpu (a -> fill );
1101+ }
0 commit comments