@@ -2009,17 +2009,14 @@ static int hclge_dbg_dump_mng_table(struct hclge_dev *hdev, char *buf, int len)
2009
2009
return 0 ;
2010
2010
}
2011
2011
2012
- #define HCLGE_DBG_TCAM_BUF_SIZE 256
2013
-
2014
2012
static int hclge_dbg_fd_tcam_read (struct hclge_dev * hdev , bool sel_x ,
2015
- char * tcam_buf ,
2013
+ struct seq_file * s ,
2016
2014
struct hclge_dbg_tcam_msg tcam_msg )
2017
2015
{
2018
2016
struct hclge_fd_tcam_config_1_cmd * req1 ;
2019
2017
struct hclge_fd_tcam_config_2_cmd * req2 ;
2020
2018
struct hclge_fd_tcam_config_3_cmd * req3 ;
2021
2019
struct hclge_desc desc [3 ];
2022
- int pos = 0 ;
2023
2020
int ret , i ;
2024
2021
__le32 * req ;
2025
2022
@@ -2041,27 +2038,23 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
2041
2038
if (ret )
2042
2039
return ret ;
2043
2040
2044
- pos += scnprintf (tcam_buf + pos , HCLGE_DBG_TCAM_BUF_SIZE - pos ,
2045
- "read result tcam key %s(%u):\n" , sel_x ? "x" : "y" ,
2046
- tcam_msg .loc );
2041
+ seq_printf (s , "read result tcam key %s(%u):\n" ,
2042
+ sel_x ? "x" : "y" , tcam_msg .loc );
2047
2043
2048
2044
/* tcam_data0 ~ tcam_data1 */
2049
2045
req = (__le32 * )req1 -> tcam_data ;
2050
2046
for (i = 0 ; i < 2 ; i ++ )
2051
- pos += scnprintf (tcam_buf + pos , HCLGE_DBG_TCAM_BUF_SIZE - pos ,
2052
- "%08x\n" , le32_to_cpu (* req ++ ));
2047
+ seq_printf (s , "%08x\n" , le32_to_cpu (* req ++ ));
2053
2048
2054
2049
/* tcam_data2 ~ tcam_data7 */
2055
2050
req = (__le32 * )req2 -> tcam_data ;
2056
2051
for (i = 0 ; i < 6 ; i ++ )
2057
- pos += scnprintf (tcam_buf + pos , HCLGE_DBG_TCAM_BUF_SIZE - pos ,
2058
- "%08x\n" , le32_to_cpu (* req ++ ));
2052
+ seq_printf (s , "%08x\n" , le32_to_cpu (* req ++ ));
2059
2053
2060
2054
/* tcam_data8 ~ tcam_data12 */
2061
2055
req = (__le32 * )req3 -> tcam_data ;
2062
2056
for (i = 0 ; i < 5 ; i ++ )
2063
- pos += scnprintf (tcam_buf + pos , HCLGE_DBG_TCAM_BUF_SIZE - pos ,
2064
- "%08x\n" , le32_to_cpu (* req ++ ));
2057
+ seq_printf (s , "%08x\n" , le32_to_cpu (* req ++ ));
2065
2058
2066
2059
return ret ;
2067
2060
}
@@ -2085,34 +2078,28 @@ static int hclge_dbg_get_rules_location(struct hclge_dev *hdev, u16 *rule_locs)
2085
2078
return cnt ;
2086
2079
}
2087
2080
2088
- static int hclge_dbg_dump_fd_tcam (struct hclge_dev * hdev , char * buf , int len )
2081
+ static int hclge_dbg_dump_fd_tcam (struct seq_file * s , void * data )
2089
2082
{
2090
- u32 rule_num = hdev -> fd_cfg . rule_num [ HCLGE_FD_STAGE_1 ] ;
2083
+ struct hclge_dev * hdev = hclge_seq_file_to_hdev ( s ) ;
2091
2084
struct hclge_dbg_tcam_msg tcam_msg ;
2092
2085
int i , ret , rule_cnt ;
2093
2086
u16 * rule_locs ;
2094
- char * tcam_buf ;
2095
- int pos = 0 ;
2087
+ u32 rule_num ;
2096
2088
2097
2089
if (!hnae3_ae_dev_fd_supported (hdev -> ae_dev )) {
2098
2090
dev_err (& hdev -> pdev -> dev ,
2099
2091
"Only FD-supported dev supports dump fd tcam\n" );
2100
2092
return - EOPNOTSUPP ;
2101
2093
}
2102
2094
2095
+ rule_num = hdev -> fd_cfg .rule_num [HCLGE_FD_STAGE_1 ];
2103
2096
if (!hdev -> hclge_fd_rule_num || !rule_num )
2104
2097
return 0 ;
2105
2098
2106
2099
rule_locs = kcalloc (rule_num , sizeof (u16 ), GFP_KERNEL );
2107
2100
if (!rule_locs )
2108
2101
return - ENOMEM ;
2109
2102
2110
- tcam_buf = kzalloc (HCLGE_DBG_TCAM_BUF_SIZE , GFP_KERNEL );
2111
- if (!tcam_buf ) {
2112
- kfree (rule_locs );
2113
- return - ENOMEM ;
2114
- }
2115
-
2116
2103
rule_cnt = hclge_dbg_get_rules_location (hdev , rule_locs );
2117
2104
if (rule_cnt < 0 ) {
2118
2105
ret = rule_cnt ;
@@ -2126,47 +2113,42 @@ static int hclge_dbg_dump_fd_tcam(struct hclge_dev *hdev, char *buf, int len)
2126
2113
tcam_msg .stage = HCLGE_FD_STAGE_1 ;
2127
2114
tcam_msg .loc = rule_locs [i ];
2128
2115
2129
- ret = hclge_dbg_fd_tcam_read (hdev , true, tcam_buf , tcam_msg );
2116
+ ret = hclge_dbg_fd_tcam_read (hdev , true, s , tcam_msg );
2130
2117
if (ret ) {
2131
2118
dev_err (& hdev -> pdev -> dev ,
2132
2119
"failed to get fd tcam key x, ret = %d\n" , ret );
2133
2120
goto out ;
2134
2121
}
2135
2122
2136
- pos += scnprintf (buf + pos , len - pos , "%s" , tcam_buf );
2137
-
2138
- ret = hclge_dbg_fd_tcam_read (hdev , false, tcam_buf , tcam_msg );
2123
+ ret = hclge_dbg_fd_tcam_read (hdev , false, s , tcam_msg );
2139
2124
if (ret ) {
2140
2125
dev_err (& hdev -> pdev -> dev ,
2141
2126
"failed to get fd tcam key y, ret = %d\n" , ret );
2142
2127
goto out ;
2143
2128
}
2144
2129
2145
- pos += scnprintf (buf + pos , len - pos , "%s" , tcam_buf );
2146
2130
}
2147
2131
2148
2132
out :
2149
- kfree (tcam_buf );
2150
2133
kfree (rule_locs );
2151
2134
return ret ;
2152
2135
}
2153
2136
2154
- static int hclge_dbg_dump_fd_counter (struct hclge_dev * hdev , char * buf , int len )
2137
+ static int hclge_dbg_dump_fd_counter (struct seq_file * s , void * data )
2155
2138
{
2139
+ struct hclge_dev * hdev = hclge_seq_file_to_hdev (s );
2156
2140
u8 func_num = pci_num_vf (hdev -> pdev ) + 1 ; /* pf and enabled vf num */
2157
2141
struct hclge_fd_ad_cnt_read_cmd * req ;
2158
2142
char str_id [HCLGE_DBG_ID_LEN ];
2159
2143
struct hclge_desc desc ;
2160
- int pos = 0 ;
2161
2144
int ret ;
2162
2145
u64 cnt ;
2163
2146
u8 i ;
2164
2147
2165
2148
if (!hnae3_ae_dev_fd_supported (hdev -> ae_dev ))
2166
2149
return - EOPNOTSUPP ;
2167
2150
2168
- pos += scnprintf (buf + pos , len - pos ,
2169
- "func_id\thit_times\n" );
2151
+ seq_puts (s , "func_id\thit_times\n" );
2170
2152
2171
2153
for (i = 0 ; i < func_num ; i ++ ) {
2172
2154
hclge_cmd_setup_basic_desc (& desc , HCLGE_OPC_FD_CNT_OP , true);
@@ -2180,8 +2162,7 @@ static int hclge_dbg_dump_fd_counter(struct hclge_dev *hdev, char *buf, int len)
2180
2162
}
2181
2163
cnt = le64_to_cpu (req -> cnt );
2182
2164
hclge_dbg_get_func_id_str (str_id , i );
2183
- pos += scnprintf (buf + pos , len - pos ,
2184
- "%s\t%llu\n" , str_id , cnt );
2165
+ seq_printf (s , "%s\t%llu\n" , str_id , cnt );
2185
2166
}
2186
2167
2187
2168
return 0 ;
@@ -3020,7 +3001,7 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
3020
3001
},
3021
3002
{
3022
3003
.cmd = HNAE3_DBG_CMD_FD_TCAM ,
3023
- .dbg_dump = hclge_dbg_dump_fd_tcam ,
3004
+ .dbg_read_func = hclge_dbg_dump_fd_tcam ,
3024
3005
},
3025
3006
{
3026
3007
.cmd = HNAE3_DBG_CMD_MAC_TNL_STATUS ,
@@ -3036,7 +3017,7 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
3036
3017
},
3037
3018
{
3038
3019
.cmd = HNAE3_DBG_CMD_FD_COUNTER ,
3039
- .dbg_dump = hclge_dbg_dump_fd_counter ,
3020
+ .dbg_read_func = hclge_dbg_dump_fd_counter ,
3040
3021
},
3041
3022
{
3042
3023
.cmd = HNAE3_DBG_CMD_UMV_INFO ,
0 commit comments