xpp: re-add setting xpd->subunits

The number of subunits per XPD (which is not trivial in BRI) has been
accidentally left out in a previous commit.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Tzafrir Cohen
2017-04-02 18:03:03 +03:00
parent 8e310fd264
commit 5b9f520e78
3 changed files with 13 additions and 3 deletions

View File

@@ -719,6 +719,15 @@ static xpd_type_t xpd_hw2xpd_type(const struct unit_descriptor *unit_descriptor)
return xpd_type;
}
int subunits_of_xpd(const struct unit_descriptor* unit_descriptor,
const xproto_table_t *proto_table) {
int ports = unit_descriptor->ports_per_chip * unit_descriptor->numchips;
return
(ports + proto_table->ports_per_subunit - 1)
/ proto_table->ports_per_subunit;
}
static int new_card(xbus_t *xbus, const struct unit_descriptor *unit_descriptor)
{
int unit = unit_descriptor->addr.unit;
@@ -764,9 +773,7 @@ static int new_card(xbus_t *xbus, const struct unit_descriptor *unit_descriptor)
xbus->echo_state.xpd_idx = XPD_IDX(unit, 0);
}
remaining_ports = ports;
subunits =
(ports + proto_table->ports_per_subunit -
1) / proto_table->ports_per_subunit;
subunits = subunits_of_xpd(unit_descriptor, proto_table);
XBUS_DBG(DEVICES, xbus,
"CARD %d xpd_type=%d/hw_type=%d ports=%d (%dx%d), "
"%d subunits, port-dir=0x%02X\n",

View File

@@ -338,6 +338,8 @@ int waitfor_xpds(xbus_t *xbus, char *buf);
int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit);
int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd);
int subunits_of_xpd(const struct unit_descriptor* unit_descriptor,
const xproto_table_t *proto_table);
/* sysfs */
int xpd_device_register(xbus_t *xbus, xpd_t *xpd);
void xpd_device_unregister(xpd_t *xpd);

View File

@@ -572,6 +572,7 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit,
xpd->unit_descriptor = *unit_descriptor;
xpd->xops = proto_table->xops;
xpd->xpd_state = XPD_STATE_START;
xpd->subunits = subunits_of_xpd(unit_descriptor, proto_table);
kref_init(&xpd->kref);
/* For USB-1 disable some channels */