Lines Matching refs:sw
43 struct tb_switch *sw = data; in tb_test_switch_put() local
45 put_device(&sw->dev); in tb_test_switch_put()
51 struct tb_switch *sw; in alloc_switch() local
55 sw = kunit_kzalloc(test, sizeof(*sw), GFP_KERNEL); in alloc_switch()
56 if (!sw) in alloc_switch()
63 sw->dev.release = tb_test_switch_release; in alloc_switch()
64 device_initialize(&sw->dev); in alloc_switch()
65 if (kunit_add_action_or_reset(test, tb_test_switch_put, sw)) in alloc_switch()
68 sw->config.upstream_port_number = upstream_port; in alloc_switch()
69 sw->config.depth = tb_route_length(route); in alloc_switch()
70 sw->config.route_hi = upper_32_bits(route); in alloc_switch()
71 sw->config.route_lo = lower_32_bits(route); in alloc_switch()
72 sw->config.enabled = 0; in alloc_switch()
73 sw->config.max_port_number = max_port_number; in alloc_switch()
75 size = (sw->config.max_port_number + 1) * sizeof(*sw->ports); in alloc_switch()
76 sw->ports = kunit_kzalloc(test, size, GFP_KERNEL); in alloc_switch()
77 if (!sw->ports) in alloc_switch()
80 for (i = 0; i <= sw->config.max_port_number; i++) { in alloc_switch()
81 sw->ports[i].sw = sw; in alloc_switch()
82 sw->ports[i].port = i; in alloc_switch()
83 sw->ports[i].config.port_number = i; in alloc_switch()
85 kunit_ida_init(test, &sw->ports[i].in_hopids); in alloc_switch()
86 kunit_ida_init(test, &sw->ports[i].out_hopids); in alloc_switch()
90 return sw; in alloc_switch()
95 struct tb_switch *sw; in alloc_host() local
97 sw = alloc_switch(test, 0, 7, 13); in alloc_host()
98 if (!sw) in alloc_host()
101 sw->config.vendor_id = 0x8086; in alloc_host()
102 sw->config.device_id = 0x9a1b; in alloc_host()
104 sw->ports[0].config.type = TB_TYPE_PORT; in alloc_host()
105 sw->ports[0].config.max_in_hop_id = 7; in alloc_host()
106 sw->ports[0].config.max_out_hop_id = 7; in alloc_host()
108 sw->ports[1].config.type = TB_TYPE_PORT; in alloc_host()
109 sw->ports[1].config.max_in_hop_id = 19; in alloc_host()
110 sw->ports[1].config.max_out_hop_id = 19; in alloc_host()
111 sw->ports[1].total_credits = 60; in alloc_host()
112 sw->ports[1].ctl_credits = 2; in alloc_host()
113 sw->ports[1].dual_link_port = &sw->ports[2]; in alloc_host()
115 sw->ports[2].config.type = TB_TYPE_PORT; in alloc_host()
116 sw->ports[2].config.max_in_hop_id = 19; in alloc_host()
117 sw->ports[2].config.max_out_hop_id = 19; in alloc_host()
118 sw->ports[2].total_credits = 60; in alloc_host()
119 sw->ports[2].ctl_credits = 2; in alloc_host()
120 sw->ports[2].dual_link_port = &sw->ports[1]; in alloc_host()
121 sw->ports[2].link_nr = 1; in alloc_host()
123 sw->ports[3].config.type = TB_TYPE_PORT; in alloc_host()
124 sw->ports[3].config.max_in_hop_id = 19; in alloc_host()
125 sw->ports[3].config.max_out_hop_id = 19; in alloc_host()
126 sw->ports[3].total_credits = 60; in alloc_host()
127 sw->ports[3].ctl_credits = 2; in alloc_host()
128 sw->ports[3].dual_link_port = &sw->ports[4]; in alloc_host()
130 sw->ports[4].config.type = TB_TYPE_PORT; in alloc_host()
131 sw->ports[4].config.max_in_hop_id = 19; in alloc_host()
132 sw->ports[4].config.max_out_hop_id = 19; in alloc_host()
133 sw->ports[4].total_credits = 60; in alloc_host()
134 sw->ports[4].ctl_credits = 2; in alloc_host()
135 sw->ports[4].dual_link_port = &sw->ports[3]; in alloc_host()
136 sw->ports[4].link_nr = 1; in alloc_host()
138 sw->ports[5].config.type = TB_TYPE_DP_HDMI_IN; in alloc_host()
139 sw->ports[5].config.max_in_hop_id = 9; in alloc_host()
140 sw->ports[5].config.max_out_hop_id = 9; in alloc_host()
141 sw->ports[5].cap_adap = -1; in alloc_host()
143 sw->ports[6].config.type = TB_TYPE_DP_HDMI_IN; in alloc_host()
144 sw->ports[6].config.max_in_hop_id = 9; in alloc_host()
145 sw->ports[6].config.max_out_hop_id = 9; in alloc_host()
146 sw->ports[6].cap_adap = -1; in alloc_host()
148 sw->ports[7].config.type = TB_TYPE_NHI; in alloc_host()
149 sw->ports[7].config.max_in_hop_id = 11; in alloc_host()
150 sw->ports[7].config.max_out_hop_id = 11; in alloc_host()
151 sw->ports[7].config.nfc_credits = 0x41800000; in alloc_host()
153 sw->ports[8].config.type = TB_TYPE_PCIE_DOWN; in alloc_host()
154 sw->ports[8].config.max_in_hop_id = 8; in alloc_host()
155 sw->ports[8].config.max_out_hop_id = 8; in alloc_host()
157 sw->ports[9].config.type = TB_TYPE_PCIE_DOWN; in alloc_host()
158 sw->ports[9].config.max_in_hop_id = 8; in alloc_host()
159 sw->ports[9].config.max_out_hop_id = 8; in alloc_host()
161 sw->ports[10].disabled = true; in alloc_host()
162 sw->ports[11].disabled = true; in alloc_host()
164 sw->ports[12].config.type = TB_TYPE_USB3_DOWN; in alloc_host()
165 sw->ports[12].config.max_in_hop_id = 8; in alloc_host()
166 sw->ports[12].config.max_out_hop_id = 8; in alloc_host()
168 sw->ports[13].config.type = TB_TYPE_USB3_DOWN; in alloc_host()
169 sw->ports[13].config.max_in_hop_id = 8; in alloc_host()
170 sw->ports[13].config.max_out_hop_id = 8; in alloc_host()
172 return sw; in alloc_host()
177 struct tb_switch *sw; in alloc_host_usb4() local
179 sw = alloc_host(test); in alloc_host_usb4()
180 if (!sw) in alloc_host_usb4()
183 sw->generation = 4; in alloc_host_usb4()
184 sw->credit_allocation = true; in alloc_host_usb4()
185 sw->max_usb3_credits = 32; in alloc_host_usb4()
186 sw->min_dp_aux_credits = 1; in alloc_host_usb4()
187 sw->min_dp_main_credits = 0; in alloc_host_usb4()
188 sw->max_pcie_credits = 64; in alloc_host_usb4()
189 sw->max_dma_credits = 14; in alloc_host_usb4()
191 return sw; in alloc_host_usb4()
196 struct tb_switch *sw; in alloc_host_br() local
198 sw = alloc_host_usb4(test); in alloc_host_br()
199 if (!sw) in alloc_host_br()
202 sw->ports[10].config.type = TB_TYPE_DP_HDMI_IN; in alloc_host_br()
203 sw->ports[10].config.max_in_hop_id = 9; in alloc_host_br()
204 sw->ports[10].config.max_out_hop_id = 9; in alloc_host_br()
205 sw->ports[10].cap_adap = -1; in alloc_host_br()
206 sw->ports[10].disabled = false; in alloc_host_br()
208 return sw; in alloc_host_br()
216 struct tb_switch *sw; in alloc_dev_default() local
218 sw = alloc_switch(test, route, 1, 19); in alloc_dev_default()
219 if (!sw) in alloc_dev_default()
222 sw->config.vendor_id = 0x8086; in alloc_dev_default()
223 sw->config.device_id = 0x15ef; in alloc_dev_default()
225 sw->ports[0].config.type = TB_TYPE_PORT; in alloc_dev_default()
226 sw->ports[0].config.max_in_hop_id = 8; in alloc_dev_default()
227 sw->ports[0].config.max_out_hop_id = 8; in alloc_dev_default()
229 sw->ports[1].config.type = TB_TYPE_PORT; in alloc_dev_default()
230 sw->ports[1].config.max_in_hop_id = 19; in alloc_dev_default()
231 sw->ports[1].config.max_out_hop_id = 19; in alloc_dev_default()
232 sw->ports[1].total_credits = 60; in alloc_dev_default()
233 sw->ports[1].ctl_credits = 2; in alloc_dev_default()
234 sw->ports[1].dual_link_port = &sw->ports[2]; in alloc_dev_default()
236 sw->ports[2].config.type = TB_TYPE_PORT; in alloc_dev_default()
237 sw->ports[2].config.max_in_hop_id = 19; in alloc_dev_default()
238 sw->ports[2].config.max_out_hop_id = 19; in alloc_dev_default()
239 sw->ports[2].total_credits = 60; in alloc_dev_default()
240 sw->ports[2].ctl_credits = 2; in alloc_dev_default()
241 sw->ports[2].dual_link_port = &sw->ports[1]; in alloc_dev_default()
242 sw->ports[2].link_nr = 1; in alloc_dev_default()
244 sw->ports[3].config.type = TB_TYPE_PORT; in alloc_dev_default()
245 sw->ports[3].config.max_in_hop_id = 19; in alloc_dev_default()
246 sw->ports[3].config.max_out_hop_id = 19; in alloc_dev_default()
247 sw->ports[3].total_credits = 60; in alloc_dev_default()
248 sw->ports[3].ctl_credits = 2; in alloc_dev_default()
249 sw->ports[3].dual_link_port = &sw->ports[4]; in alloc_dev_default()
251 sw->ports[4].config.type = TB_TYPE_PORT; in alloc_dev_default()
252 sw->ports[4].config.max_in_hop_id = 19; in alloc_dev_default()
253 sw->ports[4].config.max_out_hop_id = 19; in alloc_dev_default()
254 sw->ports[4].total_credits = 60; in alloc_dev_default()
255 sw->ports[4].ctl_credits = 2; in alloc_dev_default()
256 sw->ports[4].dual_link_port = &sw->ports[3]; in alloc_dev_default()
257 sw->ports[4].link_nr = 1; in alloc_dev_default()
259 sw->ports[5].config.type = TB_TYPE_PORT; in alloc_dev_default()
260 sw->ports[5].config.max_in_hop_id = 19; in alloc_dev_default()
261 sw->ports[5].config.max_out_hop_id = 19; in alloc_dev_default()
262 sw->ports[5].total_credits = 60; in alloc_dev_default()
263 sw->ports[5].ctl_credits = 2; in alloc_dev_default()
264 sw->ports[5].dual_link_port = &sw->ports[6]; in alloc_dev_default()
266 sw->ports[6].config.type = TB_TYPE_PORT; in alloc_dev_default()
267 sw->ports[6].config.max_in_hop_id = 19; in alloc_dev_default()
268 sw->ports[6].config.max_out_hop_id = 19; in alloc_dev_default()
269 sw->ports[6].total_credits = 60; in alloc_dev_default()
270 sw->ports[6].ctl_credits = 2; in alloc_dev_default()
271 sw->ports[6].dual_link_port = &sw->ports[5]; in alloc_dev_default()
272 sw->ports[6].link_nr = 1; in alloc_dev_default()
274 sw->ports[7].config.type = TB_TYPE_PORT; in alloc_dev_default()
275 sw->ports[7].config.max_in_hop_id = 19; in alloc_dev_default()
276 sw->ports[7].config.max_out_hop_id = 19; in alloc_dev_default()
277 sw->ports[7].total_credits = 60; in alloc_dev_default()
278 sw->ports[7].ctl_credits = 2; in alloc_dev_default()
279 sw->ports[7].dual_link_port = &sw->ports[8]; in alloc_dev_default()
281 sw->ports[8].config.type = TB_TYPE_PORT; in alloc_dev_default()
282 sw->ports[8].config.max_in_hop_id = 19; in alloc_dev_default()
283 sw->ports[8].config.max_out_hop_id = 19; in alloc_dev_default()
284 sw->ports[8].total_credits = 60; in alloc_dev_default()
285 sw->ports[8].ctl_credits = 2; in alloc_dev_default()
286 sw->ports[8].dual_link_port = &sw->ports[7]; in alloc_dev_default()
287 sw->ports[8].link_nr = 1; in alloc_dev_default()
289 sw->ports[9].config.type = TB_TYPE_PCIE_UP; in alloc_dev_default()
290 sw->ports[9].config.max_in_hop_id = 8; in alloc_dev_default()
291 sw->ports[9].config.max_out_hop_id = 8; in alloc_dev_default()
293 sw->ports[10].config.type = TB_TYPE_PCIE_DOWN; in alloc_dev_default()
294 sw->ports[10].config.max_in_hop_id = 8; in alloc_dev_default()
295 sw->ports[10].config.max_out_hop_id = 8; in alloc_dev_default()
297 sw->ports[11].config.type = TB_TYPE_PCIE_DOWN; in alloc_dev_default()
298 sw->ports[11].config.max_in_hop_id = 8; in alloc_dev_default()
299 sw->ports[11].config.max_out_hop_id = 8; in alloc_dev_default()
301 sw->ports[12].config.type = TB_TYPE_PCIE_DOWN; in alloc_dev_default()
302 sw->ports[12].config.max_in_hop_id = 8; in alloc_dev_default()
303 sw->ports[12].config.max_out_hop_id = 8; in alloc_dev_default()
305 sw->ports[13].config.type = TB_TYPE_DP_HDMI_OUT; in alloc_dev_default()
306 sw->ports[13].config.max_in_hop_id = 9; in alloc_dev_default()
307 sw->ports[13].config.max_out_hop_id = 9; in alloc_dev_default()
308 sw->ports[13].cap_adap = -1; in alloc_dev_default()
310 sw->ports[14].config.type = TB_TYPE_DP_HDMI_OUT; in alloc_dev_default()
311 sw->ports[14].config.max_in_hop_id = 9; in alloc_dev_default()
312 sw->ports[14].config.max_out_hop_id = 9; in alloc_dev_default()
313 sw->ports[14].cap_adap = -1; in alloc_dev_default()
315 sw->ports[15].disabled = true; in alloc_dev_default()
317 sw->ports[16].config.type = TB_TYPE_USB3_UP; in alloc_dev_default()
318 sw->ports[16].config.max_in_hop_id = 8; in alloc_dev_default()
319 sw->ports[16].config.max_out_hop_id = 8; in alloc_dev_default()
321 sw->ports[17].config.type = TB_TYPE_USB3_DOWN; in alloc_dev_default()
322 sw->ports[17].config.max_in_hop_id = 8; in alloc_dev_default()
323 sw->ports[17].config.max_out_hop_id = 8; in alloc_dev_default()
325 sw->ports[18].config.type = TB_TYPE_USB3_DOWN; in alloc_dev_default()
326 sw->ports[18].config.max_in_hop_id = 8; in alloc_dev_default()
327 sw->ports[18].config.max_out_hop_id = 8; in alloc_dev_default()
329 sw->ports[19].config.type = TB_TYPE_USB3_DOWN; in alloc_dev_default()
330 sw->ports[19].config.max_in_hop_id = 8; in alloc_dev_default()
331 sw->ports[19].config.max_out_hop_id = 8; in alloc_dev_default()
334 return sw; in alloc_dev_default()
337 upstream_port = tb_upstream_port(sw); in alloc_dev_default()
358 return sw; in alloc_dev_default()
365 struct tb_switch *sw; in alloc_dev_with_dpin() local
367 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_with_dpin()
368 if (!sw) in alloc_dev_with_dpin()
371 sw->ports[13].config.type = TB_TYPE_DP_HDMI_IN; in alloc_dev_with_dpin()
372 sw->ports[13].config.max_in_hop_id = 9; in alloc_dev_with_dpin()
373 sw->ports[13].config.max_out_hop_id = 9; in alloc_dev_with_dpin()
375 sw->ports[14].config.type = TB_TYPE_DP_HDMI_IN; in alloc_dev_with_dpin()
376 sw->ports[14].config.max_in_hop_id = 9; in alloc_dev_with_dpin()
377 sw->ports[14].config.max_out_hop_id = 9; in alloc_dev_with_dpin()
379 return sw; in alloc_dev_with_dpin()
386 struct tb_switch *sw; in alloc_dev_without_dp() local
389 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_without_dp()
390 if (!sw) in alloc_dev_without_dp()
401 sw->ports[i].disabled = true; in alloc_dev_without_dp()
404 sw->ports[i].disabled = true; in alloc_dev_without_dp()
406 sw->ports[13].cap_adap = 0; in alloc_dev_without_dp()
407 sw->ports[14].cap_adap = 0; in alloc_dev_without_dp()
410 sw->ports[i].disabled = true; in alloc_dev_without_dp()
412 sw->generation = 4; in alloc_dev_without_dp()
413 sw->credit_allocation = true; in alloc_dev_without_dp()
414 sw->max_usb3_credits = 109; in alloc_dev_without_dp()
415 sw->min_dp_aux_credits = 0; in alloc_dev_without_dp()
416 sw->min_dp_main_credits = 0; in alloc_dev_without_dp()
417 sw->max_pcie_credits = 30; in alloc_dev_without_dp()
418 sw->max_dma_credits = 1; in alloc_dev_without_dp()
420 return sw; in alloc_dev_without_dp()
427 struct tb_switch *sw; in alloc_dev_usb4() local
429 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_usb4()
430 if (!sw) in alloc_dev_usb4()
433 sw->generation = 4; in alloc_dev_usb4()
434 sw->credit_allocation = true; in alloc_dev_usb4()
435 sw->max_usb3_credits = 14; in alloc_dev_usb4()
436 sw->min_dp_aux_credits = 1; in alloc_dev_usb4()
437 sw->min_dp_main_credits = 18; in alloc_dev_usb4()
438 sw->max_pcie_credits = 32; in alloc_dev_usb4()
439 sw->max_dma_credits = 14; in alloc_dev_usb4()
441 return sw; in alloc_dev_usb4()
532 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
544 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
591 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
603 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
654 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
666 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
738 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
750 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
841 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
853 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
937 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
941 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
999 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
1003 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
1079 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1083 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1159 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1163 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1251 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1255 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1343 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1347 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()