for (i = 0; i < num_hops; i++) {
in_port = tb_next_port_on_path(src, dst, out_port); if (!in_port) goto err;
/* When lanes are bonded primary link must be used */ if (!in_port->bonded && in_port->dual_link_port &&
in_port->link_nr != link_nr)
in_port = in_port->dual_link_port;
ret = tb_port_alloc_in_hopid(in_port, in_hopid, in_hopid); if (ret < 0) goto err;
in_hopid = ret;
out_port = tb_next_port_on_path(src, dst, in_port); if (!out_port) goto err;
/** *tb_path_free()-freeapath *@path:Pathtofree * *Freesapath.Thepathdoesnotneedtobedeactivated.
*/ void tb_path_free(struct tb_path *path)
{ if (path->alloc_hopid) { int i;
for (i = 0; i < path->path_length; i++) { conststruct tb_path_hop *hop = &path->hops[i];
if (hop->in_port)
tb_port_release_in_hopid(hop->in_port,
hop->in_hop_index); if (hop->out_port)
tb_port_release_out_hopid(hop->out_port,
hop->next_hop_index);
}
}
kfree(path->hops);
kfree(path);
}
staticvoid __tb_path_deallocate_nfc(struct tb_path *path, int first_hop)
{ int i, res; for (i = first_hop; i < path->path_length; i++) {
res = tb_port_add_nfc_credits(path->hops[i].in_port,
-path->hops[i].nfc_credits); if (res)
tb_port_warn(path->hops[i].in_port, "nfc credits deallocation failed for hop %d\n",
i);
}
}
staticint __tb_path_deactivate_hop(struct tb_port *port, int hop_index, bool clear_fc)
{ struct tb_regs_hop hop;
ktime_t timeout; int ret;
/* Disable the path */
ret = tb_port_read(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2); if (ret) return ret;
/* Already disabled */ if (!hop.enable) return0;
hop.enable = 0;
ret = tb_port_write(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2); if (ret) return ret;
/* Wait until it is drained */
timeout = ktime_add_ms(ktime_get(), 500); do {
ret = tb_port_read(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2); if (ret) return ret;
if (!hop.pending) { if (clear_fc) { /* *Clearflowcontrol.Protocoladapters *IFCandISEbitsarevendordefined *intheUSB4specsoweclearthem *onlyforpre-USB4adapters.
*/ if (!tb_switch_is_usb4(port->sw)) {
hop.ingress_fc = 0;
hop.ingress_shared_buffer = 0;
}
hop.egress_fc = 0;
hop.egress_shared_buffer = 0;
usleep_range(10, 20);
} while (ktime_before(ktime_get(), timeout));
return -ETIMEDOUT;
}
/** *tb_path_deactivate_hop()-Deactivateonepathinpathconfigspace *@port:Laneorprotocoladapter *@hop_index:HopIDofthepathtobecleared * *Thisdeactivatesorclearsasinglepathconfigspaceentryat *@hop_index.Returns%0insuccessandnegativeerrnootherwise.
*/ int tb_path_deactivate_hop(struct tb_port *port, int hop_index)
{ return __tb_path_deactivate_hop(port, hop_index, true);
}
staticvoid __tb_path_deactivate_hops(struct tb_path *path, int first_hop)
{ int i, res;
for (i = first_hop; i < path->path_length; i++) {
res = __tb_path_deactivate_hop(path->hops[i].in_port,
path->hops[i].in_hop_index,
path->clear_fc); if (res && res != -ENODEV)
tb_port_warn(path->hops[i].in_port, "hop deactivation failed for hop %d, index %d\n",
i, path->hops[i].in_hop_index);
}
}
void tb_path_deactivate(struct tb_path *path)
{ if (!path->activated) {
tb_WARN(path->tb, "trying to deactivate an inactive path\n"); return;
}
tb_dbg(path->tb, "deactivating %s path from %llx:%u to %llx:%u\n",
path->name, tb_route(path->hops[0].in_port->sw),
path->hops[0].in_port->port,
tb_route(path->hops[path->path_length - 1].out_port->sw),
path->hops[path->path_length - 1].out_port->port);
__tb_path_deactivate_hops(path, 0);
__tb_path_deallocate_nfc(path, 0);
path->activated = false;
}
/** *tb_path_activate()-activateapath *@path:Pathtoactivate * *Activateapathstartingwiththelasthopanditeratingbackwards.The *callermustfillpath->hopsbeforecallingtb_path_activate(). * *Return:Returns0onsuccessoranerrorcodeonfailure.
*/ int tb_path_activate(struct tb_path *path)
{ int i, res; enum tb_path_port out_mask, in_mask; if (path->activated) {
tb_WARN(path->tb, "trying to activate already activated path\n"); return -EINVAL;
}
tb_dbg(path->tb, "activating %s path from %llx:%u to %llx:%u\n",
path->name, tb_route(path->hops[0].in_port->sw),
path->hops[0].in_port->port,
tb_route(path->hops[path->path_length - 1].out_port->sw),
path->hops[path->path_length - 1].out_port->port);
/* Clear counters. */ for (i = path->path_length - 1; i >= 0; i--) { if (path->hops[i].in_counter_index == -1) continue;
res = tb_port_clear_counter(path->hops[i].in_port,
path->hops[i].in_counter_index); if (res) goto err;
}
/* Add non flow controlled credits. */ for (i = path->path_length - 1; i >= 0; i--) {
res = tb_port_add_nfc_credits(path->hops[i].in_port,
path->hops[i].nfc_credits); if (res) {
__tb_path_deallocate_nfc(path, i); goto err;
}
}
/* Activate hops. */ for (i = path->path_length - 1; i >= 0; i--) { struct tb_regs_hop hop = { 0 };
/* If it is left active deactivate it first */
__tb_path_deactivate_hop(path->hops[i].in_port,
path->hops[i].in_hop_index, path->clear_fc);
/** *tb_path_is_invalid()-checkwhetheranyportsonthepathareinvalid *@path:Pathtocheck * *Return:Returnstrueifthepathisinvalid,falseotherwise.
*/ bool tb_path_is_invalid(struct tb_path *path)
{ int i = 0; for (i = 0; i < path->path_length; i++) { if (path->hops[i].in_port->sw->is_unplugged) returntrue; if (path->hops[i].out_port->sw->is_unplugged) returntrue;
} returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.