Lines Matching refs:sw

39 	struct tb_switch *sw;  in alloc_switch()  local
43 sw = kunit_kzalloc(test, sizeof(*sw), GFP_KERNEL); in alloc_switch()
44 if (!sw) in alloc_switch()
47 sw->config.upstream_port_number = upstream_port; in alloc_switch()
48 sw->config.depth = tb_route_length(route); in alloc_switch()
49 sw->config.route_hi = upper_32_bits(route); in alloc_switch()
50 sw->config.route_lo = lower_32_bits(route); in alloc_switch()
51 sw->config.enabled = 0; in alloc_switch()
52 sw->config.max_port_number = max_port_number; in alloc_switch()
54 size = (sw->config.max_port_number + 1) * sizeof(*sw->ports); in alloc_switch()
55 sw->ports = kunit_kzalloc(test, size, GFP_KERNEL); in alloc_switch()
56 if (!sw->ports) in alloc_switch()
59 for (i = 0; i <= sw->config.max_port_number; i++) { in alloc_switch()
60 sw->ports[i].sw = sw; in alloc_switch()
61 sw->ports[i].port = i; in alloc_switch()
62 sw->ports[i].config.port_number = i; in alloc_switch()
64 kunit_ida_init(test, &sw->ports[i].in_hopids); in alloc_switch()
65 kunit_ida_init(test, &sw->ports[i].out_hopids); in alloc_switch()
69 return sw; in alloc_switch()
74 struct tb_switch *sw; in alloc_host() local
76 sw = alloc_switch(test, 0, 7, 13); in alloc_host()
77 if (!sw) in alloc_host()
80 sw->config.vendor_id = 0x8086; in alloc_host()
81 sw->config.device_id = 0x9a1b; in alloc_host()
83 sw->ports[0].config.type = TB_TYPE_PORT; in alloc_host()
84 sw->ports[0].config.max_in_hop_id = 7; in alloc_host()
85 sw->ports[0].config.max_out_hop_id = 7; in alloc_host()
87 sw->ports[1].config.type = TB_TYPE_PORT; in alloc_host()
88 sw->ports[1].config.max_in_hop_id = 19; in alloc_host()
89 sw->ports[1].config.max_out_hop_id = 19; in alloc_host()
90 sw->ports[1].total_credits = 60; in alloc_host()
91 sw->ports[1].ctl_credits = 2; in alloc_host()
92 sw->ports[1].dual_link_port = &sw->ports[2]; in alloc_host()
94 sw->ports[2].config.type = TB_TYPE_PORT; in alloc_host()
95 sw->ports[2].config.max_in_hop_id = 19; in alloc_host()
96 sw->ports[2].config.max_out_hop_id = 19; in alloc_host()
97 sw->ports[2].total_credits = 60; in alloc_host()
98 sw->ports[2].ctl_credits = 2; in alloc_host()
99 sw->ports[2].dual_link_port = &sw->ports[1]; in alloc_host()
100 sw->ports[2].link_nr = 1; in alloc_host()
102 sw->ports[3].config.type = TB_TYPE_PORT; in alloc_host()
103 sw->ports[3].config.max_in_hop_id = 19; in alloc_host()
104 sw->ports[3].config.max_out_hop_id = 19; in alloc_host()
105 sw->ports[3].total_credits = 60; in alloc_host()
106 sw->ports[3].ctl_credits = 2; in alloc_host()
107 sw->ports[3].dual_link_port = &sw->ports[4]; in alloc_host()
109 sw->ports[4].config.type = TB_TYPE_PORT; in alloc_host()
110 sw->ports[4].config.max_in_hop_id = 19; in alloc_host()
111 sw->ports[4].config.max_out_hop_id = 19; in alloc_host()
112 sw->ports[4].total_credits = 60; in alloc_host()
113 sw->ports[4].ctl_credits = 2; in alloc_host()
114 sw->ports[4].dual_link_port = &sw->ports[3]; in alloc_host()
115 sw->ports[4].link_nr = 1; in alloc_host()
117 sw->ports[5].config.type = TB_TYPE_DP_HDMI_IN; in alloc_host()
118 sw->ports[5].config.max_in_hop_id = 9; in alloc_host()
119 sw->ports[5].config.max_out_hop_id = 9; in alloc_host()
120 sw->ports[5].cap_adap = -1; in alloc_host()
122 sw->ports[6].config.type = TB_TYPE_DP_HDMI_IN; in alloc_host()
123 sw->ports[6].config.max_in_hop_id = 9; in alloc_host()
124 sw->ports[6].config.max_out_hop_id = 9; in alloc_host()
125 sw->ports[6].cap_adap = -1; in alloc_host()
127 sw->ports[7].config.type = TB_TYPE_NHI; in alloc_host()
128 sw->ports[7].config.max_in_hop_id = 11; in alloc_host()
129 sw->ports[7].config.max_out_hop_id = 11; in alloc_host()
130 sw->ports[7].config.nfc_credits = 0x41800000; in alloc_host()
132 sw->ports[8].config.type = TB_TYPE_PCIE_DOWN; in alloc_host()
133 sw->ports[8].config.max_in_hop_id = 8; in alloc_host()
134 sw->ports[8].config.max_out_hop_id = 8; in alloc_host()
136 sw->ports[9].config.type = TB_TYPE_PCIE_DOWN; in alloc_host()
137 sw->ports[9].config.max_in_hop_id = 8; in alloc_host()
138 sw->ports[9].config.max_out_hop_id = 8; in alloc_host()
140 sw->ports[10].disabled = true; in alloc_host()
141 sw->ports[11].disabled = true; in alloc_host()
143 sw->ports[12].config.type = TB_TYPE_USB3_DOWN; in alloc_host()
144 sw->ports[12].config.max_in_hop_id = 8; in alloc_host()
145 sw->ports[12].config.max_out_hop_id = 8; in alloc_host()
147 sw->ports[13].config.type = TB_TYPE_USB3_DOWN; in alloc_host()
148 sw->ports[13].config.max_in_hop_id = 8; in alloc_host()
149 sw->ports[13].config.max_out_hop_id = 8; in alloc_host()
151 return sw; in alloc_host()
156 struct tb_switch *sw; in alloc_host_usb4() local
158 sw = alloc_host(test); in alloc_host_usb4()
159 if (!sw) in alloc_host_usb4()
162 sw->generation = 4; in alloc_host_usb4()
163 sw->credit_allocation = true; in alloc_host_usb4()
164 sw->max_usb3_credits = 32; in alloc_host_usb4()
165 sw->min_dp_aux_credits = 1; in alloc_host_usb4()
166 sw->min_dp_main_credits = 0; in alloc_host_usb4()
167 sw->max_pcie_credits = 64; in alloc_host_usb4()
168 sw->max_dma_credits = 14; in alloc_host_usb4()
170 return sw; in alloc_host_usb4()
175 struct tb_switch *sw; in alloc_host_br() local
177 sw = alloc_host_usb4(test); in alloc_host_br()
178 if (!sw) in alloc_host_br()
181 sw->ports[10].config.type = TB_TYPE_DP_HDMI_IN; in alloc_host_br()
182 sw->ports[10].config.max_in_hop_id = 9; in alloc_host_br()
183 sw->ports[10].config.max_out_hop_id = 9; in alloc_host_br()
184 sw->ports[10].cap_adap = -1; in alloc_host_br()
185 sw->ports[10].disabled = false; in alloc_host_br()
187 return sw; in alloc_host_br()
195 struct tb_switch *sw; in alloc_dev_default() local
197 sw = alloc_switch(test, route, 1, 19); in alloc_dev_default()
198 if (!sw) in alloc_dev_default()
201 sw->config.vendor_id = 0x8086; in alloc_dev_default()
202 sw->config.device_id = 0x15ef; in alloc_dev_default()
204 sw->ports[0].config.type = TB_TYPE_PORT; in alloc_dev_default()
205 sw->ports[0].config.max_in_hop_id = 8; in alloc_dev_default()
206 sw->ports[0].config.max_out_hop_id = 8; in alloc_dev_default()
208 sw->ports[1].config.type = TB_TYPE_PORT; in alloc_dev_default()
209 sw->ports[1].config.max_in_hop_id = 19; in alloc_dev_default()
210 sw->ports[1].config.max_out_hop_id = 19; in alloc_dev_default()
211 sw->ports[1].total_credits = 60; in alloc_dev_default()
212 sw->ports[1].ctl_credits = 2; in alloc_dev_default()
213 sw->ports[1].dual_link_port = &sw->ports[2]; in alloc_dev_default()
215 sw->ports[2].config.type = TB_TYPE_PORT; in alloc_dev_default()
216 sw->ports[2].config.max_in_hop_id = 19; in alloc_dev_default()
217 sw->ports[2].config.max_out_hop_id = 19; in alloc_dev_default()
218 sw->ports[2].total_credits = 60; in alloc_dev_default()
219 sw->ports[2].ctl_credits = 2; in alloc_dev_default()
220 sw->ports[2].dual_link_port = &sw->ports[1]; in alloc_dev_default()
221 sw->ports[2].link_nr = 1; in alloc_dev_default()
223 sw->ports[3].config.type = TB_TYPE_PORT; in alloc_dev_default()
224 sw->ports[3].config.max_in_hop_id = 19; in alloc_dev_default()
225 sw->ports[3].config.max_out_hop_id = 19; in alloc_dev_default()
226 sw->ports[3].total_credits = 60; in alloc_dev_default()
227 sw->ports[3].ctl_credits = 2; in alloc_dev_default()
228 sw->ports[3].dual_link_port = &sw->ports[4]; in alloc_dev_default()
230 sw->ports[4].config.type = TB_TYPE_PORT; in alloc_dev_default()
231 sw->ports[4].config.max_in_hop_id = 19; in alloc_dev_default()
232 sw->ports[4].config.max_out_hop_id = 19; in alloc_dev_default()
233 sw->ports[4].total_credits = 60; in alloc_dev_default()
234 sw->ports[4].ctl_credits = 2; in alloc_dev_default()
235 sw->ports[4].dual_link_port = &sw->ports[3]; in alloc_dev_default()
236 sw->ports[4].link_nr = 1; in alloc_dev_default()
238 sw->ports[5].config.type = TB_TYPE_PORT; in alloc_dev_default()
239 sw->ports[5].config.max_in_hop_id = 19; in alloc_dev_default()
240 sw->ports[5].config.max_out_hop_id = 19; in alloc_dev_default()
241 sw->ports[5].total_credits = 60; in alloc_dev_default()
242 sw->ports[5].ctl_credits = 2; in alloc_dev_default()
243 sw->ports[5].dual_link_port = &sw->ports[6]; in alloc_dev_default()
245 sw->ports[6].config.type = TB_TYPE_PORT; in alloc_dev_default()
246 sw->ports[6].config.max_in_hop_id = 19; in alloc_dev_default()
247 sw->ports[6].config.max_out_hop_id = 19; in alloc_dev_default()
248 sw->ports[6].total_credits = 60; in alloc_dev_default()
249 sw->ports[6].ctl_credits = 2; in alloc_dev_default()
250 sw->ports[6].dual_link_port = &sw->ports[5]; in alloc_dev_default()
251 sw->ports[6].link_nr = 1; in alloc_dev_default()
253 sw->ports[7].config.type = TB_TYPE_PORT; in alloc_dev_default()
254 sw->ports[7].config.max_in_hop_id = 19; in alloc_dev_default()
255 sw->ports[7].config.max_out_hop_id = 19; in alloc_dev_default()
256 sw->ports[7].total_credits = 60; in alloc_dev_default()
257 sw->ports[7].ctl_credits = 2; in alloc_dev_default()
258 sw->ports[7].dual_link_port = &sw->ports[8]; in alloc_dev_default()
260 sw->ports[8].config.type = TB_TYPE_PORT; in alloc_dev_default()
261 sw->ports[8].config.max_in_hop_id = 19; in alloc_dev_default()
262 sw->ports[8].config.max_out_hop_id = 19; in alloc_dev_default()
263 sw->ports[8].total_credits = 60; in alloc_dev_default()
264 sw->ports[8].ctl_credits = 2; in alloc_dev_default()
265 sw->ports[8].dual_link_port = &sw->ports[7]; in alloc_dev_default()
266 sw->ports[8].link_nr = 1; in alloc_dev_default()
268 sw->ports[9].config.type = TB_TYPE_PCIE_UP; in alloc_dev_default()
269 sw->ports[9].config.max_in_hop_id = 8; in alloc_dev_default()
270 sw->ports[9].config.max_out_hop_id = 8; in alloc_dev_default()
272 sw->ports[10].config.type = TB_TYPE_PCIE_DOWN; in alloc_dev_default()
273 sw->ports[10].config.max_in_hop_id = 8; in alloc_dev_default()
274 sw->ports[10].config.max_out_hop_id = 8; in alloc_dev_default()
276 sw->ports[11].config.type = TB_TYPE_PCIE_DOWN; in alloc_dev_default()
277 sw->ports[11].config.max_in_hop_id = 8; in alloc_dev_default()
278 sw->ports[11].config.max_out_hop_id = 8; in alloc_dev_default()
280 sw->ports[12].config.type = TB_TYPE_PCIE_DOWN; in alloc_dev_default()
281 sw->ports[12].config.max_in_hop_id = 8; in alloc_dev_default()
282 sw->ports[12].config.max_out_hop_id = 8; in alloc_dev_default()
284 sw->ports[13].config.type = TB_TYPE_DP_HDMI_OUT; in alloc_dev_default()
285 sw->ports[13].config.max_in_hop_id = 9; in alloc_dev_default()
286 sw->ports[13].config.max_out_hop_id = 9; in alloc_dev_default()
287 sw->ports[13].cap_adap = -1; in alloc_dev_default()
289 sw->ports[14].config.type = TB_TYPE_DP_HDMI_OUT; in alloc_dev_default()
290 sw->ports[14].config.max_in_hop_id = 9; in alloc_dev_default()
291 sw->ports[14].config.max_out_hop_id = 9; in alloc_dev_default()
292 sw->ports[14].cap_adap = -1; in alloc_dev_default()
294 sw->ports[15].disabled = true; in alloc_dev_default()
296 sw->ports[16].config.type = TB_TYPE_USB3_UP; in alloc_dev_default()
297 sw->ports[16].config.max_in_hop_id = 8; in alloc_dev_default()
298 sw->ports[16].config.max_out_hop_id = 8; in alloc_dev_default()
300 sw->ports[17].config.type = TB_TYPE_USB3_DOWN; in alloc_dev_default()
301 sw->ports[17].config.max_in_hop_id = 8; in alloc_dev_default()
302 sw->ports[17].config.max_out_hop_id = 8; in alloc_dev_default()
304 sw->ports[18].config.type = TB_TYPE_USB3_DOWN; in alloc_dev_default()
305 sw->ports[18].config.max_in_hop_id = 8; in alloc_dev_default()
306 sw->ports[18].config.max_out_hop_id = 8; in alloc_dev_default()
308 sw->ports[19].config.type = TB_TYPE_USB3_DOWN; in alloc_dev_default()
309 sw->ports[19].config.max_in_hop_id = 8; in alloc_dev_default()
310 sw->ports[19].config.max_out_hop_id = 8; in alloc_dev_default()
313 return sw; in alloc_dev_default()
316 upstream_port = tb_upstream_port(sw); in alloc_dev_default()
337 return sw; in alloc_dev_default()
344 struct tb_switch *sw; in alloc_dev_with_dpin() local
346 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_with_dpin()
347 if (!sw) in alloc_dev_with_dpin()
350 sw->ports[13].config.type = TB_TYPE_DP_HDMI_IN; in alloc_dev_with_dpin()
351 sw->ports[13].config.max_in_hop_id = 9; in alloc_dev_with_dpin()
352 sw->ports[13].config.max_out_hop_id = 9; in alloc_dev_with_dpin()
354 sw->ports[14].config.type = TB_TYPE_DP_HDMI_IN; in alloc_dev_with_dpin()
355 sw->ports[14].config.max_in_hop_id = 9; in alloc_dev_with_dpin()
356 sw->ports[14].config.max_out_hop_id = 9; in alloc_dev_with_dpin()
358 return sw; in alloc_dev_with_dpin()
365 struct tb_switch *sw; in alloc_dev_without_dp() local
368 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_without_dp()
369 if (!sw) in alloc_dev_without_dp()
380 sw->ports[i].disabled = true; in alloc_dev_without_dp()
383 sw->ports[i].disabled = true; in alloc_dev_without_dp()
385 sw->ports[13].cap_adap = 0; in alloc_dev_without_dp()
386 sw->ports[14].cap_adap = 0; in alloc_dev_without_dp()
389 sw->ports[i].disabled = true; in alloc_dev_without_dp()
391 sw->generation = 4; in alloc_dev_without_dp()
392 sw->credit_allocation = true; in alloc_dev_without_dp()
393 sw->max_usb3_credits = 109; in alloc_dev_without_dp()
394 sw->min_dp_aux_credits = 0; in alloc_dev_without_dp()
395 sw->min_dp_main_credits = 0; in alloc_dev_without_dp()
396 sw->max_pcie_credits = 30; in alloc_dev_without_dp()
397 sw->max_dma_credits = 1; in alloc_dev_without_dp()
399 return sw; in alloc_dev_without_dp()
406 struct tb_switch *sw; in alloc_dev_usb4() local
408 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_usb4()
409 if (!sw) in alloc_dev_usb4()
412 sw->generation = 4; in alloc_dev_usb4()
413 sw->credit_allocation = true; in alloc_dev_usb4()
414 sw->max_usb3_credits = 14; in alloc_dev_usb4()
415 sw->min_dp_aux_credits = 1; in alloc_dev_usb4()
416 sw->min_dp_main_credits = 18; in alloc_dev_usb4()
417 sw->max_pcie_credits = 32; in alloc_dev_usb4()
418 sw->max_dma_credits = 14; in alloc_dev_usb4()
420 return sw; in alloc_dev_usb4()
511 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
523 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
570 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
582 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
633 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
645 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
717 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
729 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
820 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
832 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
916 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
920 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
978 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
982 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
1058 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1062 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1138 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1142 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1230 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1234 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1322 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1326 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()