/** * tcw_finalize - finalize tcw length fields and tidaw list * @tcw: pointer to the tcw * @num_tidaws: the number of tidaws used to address input/output data or zero * if no tida is used * * Calculate the input-/output-count and tccbl field in the tcw, add a * tcat the tccb and terminate the data tidaw list if used. * * Note: in case input- or output-tida is used, the tidaw-list must be stored * in contiguous storage (no ttic). The tcal field in the tccb must be * up-to-date. */ void tcw_finalize(struct tcw *tcw, int num_tidaws) { struct tidaw *tidaw; struct tccb *tccb; struct tccb_tcat *tcat; u32 count; /* Terminate tidaw list. */ tidaw = tcw_get_data(tcw); if (num_tidaws > 0) tidaw[num_tidaws - 1].flags |= TIDAW_FLAGS_LAST; /* Add tcat to tccb. */ tccb = tcw_get_tccb(tcw); tcat = (struct tccb_tcat *) &tccb->tca[tca_size(tccb)]; memset(tcat, 0, sizeof(*tcat)); /* Calculate tcw input/output count and tcat transport count. */ count = calc_dcw_count(tccb); if (tcw->w && (tcw->flags & TCW_FLAGS_OUTPUT_TIDA)) count += calc_cbc_size(tidaw, num_tidaws); if (tcw->r) tcw->input_count = count; else if (tcw->w) tcw->output_count = count; tcat->count = ALIGN(count, 4) + 4; /* Calculate tccbl. */ tcw->tccbl = (sizeof(struct tccb) + tca_size(tccb) + sizeof(struct tccb_tcat) - 20) >> 2; }
void tcw_finalize(struct tcw *tcw, int num_tidaws) { struct tidaw *tidaw; struct tccb *tccb; struct tccb_tcat *tcat; u32 count; tidaw = tcw_get_data(tcw); if (num_tidaws > 0) tidaw[num_tidaws - 1].flags |= TIDAW_FLAGS_LAST; tccb = tcw_get_tccb(tcw); tcat = (struct tccb_tcat *) &tccb->tca[tca_size(tccb)]; memset(tcat, 0, sizeof(tcat)); count = calc_dcw_count(tccb); if (tcw->w && (tcw->flags & TCW_FLAGS_OUTPUT_TIDA)) count += calc_cbc_size(tidaw, num_tidaws); if (tcw->r) tcw->input_count = count; else if (tcw->w) tcw->output_count = count; tcat->count = ALIGN(count, 4) + 4; tcw->tccbl = (sizeof(struct tccb) + tca_size(tccb) + sizeof(struct tccb_tcat) - 20) >> 2; }
/** * tcw_add_tidaw - add a tidaw to a tcw * @tcw: the tcw address * @num_tidaws: the current number of tidaws * @flags: flags for the new tidaw * @addr: address value for the new tidaw * @count: count value for the new tidaw * * Add a new tidaw to the input/output data tidaw-list of the specified tcw * (depending on the value of the r-flag and w-flag) and return a pointer to * the new tidaw. * * Note: the tidaw-list is assumed to be contiguous with no ttics. The caller * must ensure that there is enough space for the new tidaw. The last-tidaw * flag for the last tidaw in the list will be set by tcw_finalize. */ struct tidaw *tcw_add_tidaw(struct tcw *tcw, int num_tidaws, u8 flags, void *addr, u32 count) { struct tidaw *tidaw; /* Add tidaw to tidaw-list. */ tidaw = ((struct tidaw *) tcw_get_data(tcw)) + num_tidaws; memset(tidaw, 0, sizeof(struct tidaw)); tidaw->flags = flags; tidaw->count = count; tidaw->addr = (u64) ((addr_t) addr); return tidaw; }