Deleted Added
full compact
54c54
< __FBSDID("$FreeBSD: head/sys/dev/mfi/mfi.c 174779 2007-12-19 17:22:07Z ambrisko $");
---
> __FBSDID("$FreeBSD: head/sys/dev/mfi/mfi.c 175897 2008-02-02 17:29:28Z ambrisko $");
576c576
< if (hdr->sg_count) {
---
> if (cm->cm_data != NULL && hdr->sg_count) {
2095,2099c2095,2108
< ioc->mfi_sgl_off); /* Linux can do 2 frames ? */
< cm->cm_total_frame_size = ioc->mfi_sgl_off;
< cm->cm_sg =
< (union mfi_sgl *)&cm->cm_frame->bytes[ioc->mfi_sgl_off];
< cm->cm_flags = MFI_CMD_DATAIN | MFI_CMD_DATAOUT;
---
> 2 * MFI_DCMD_FRAME_SIZE); /* this isn't quite right */
> cm->cm_total_frame_size = (sizeof(union mfi_sgl) * ioc->mfi_sge_count) + ioc->mfi_sgl_off;
> if (ioc->mfi_sge_count) {
> cm->cm_sg =
> (union mfi_sgl *)&cm->cm_frame->bytes[ioc->mfi_sgl_off];
> }
> cm->cm_flags = 0;
> if (cm->cm_frame->header.flags & MFI_FRAME_DATAIN)
> cm->cm_flags |= MFI_CMD_DATAIN;
> if (cm->cm_frame->header.flags & MFI_FRAME_DATAOUT)
> cm->cm_flags |= MFI_CMD_DATAOUT;
> /* Legacy app shim */
> if (cm->cm_flags == 0)
> cm->cm_flags |= MFI_CMD_DATAIN | MFI_CMD_DATAOUT;
2101,2105c2110,2118
< cm->cm_data = data = malloc(cm->cm_len, M_MFIBUF,
< M_WAITOK | M_ZERO);
< if (cm->cm_data == NULL) {
< device_printf(sc->mfi_dev, "Malloc failed\n");
< goto out;
---
> if (cm->cm_flags & (MFI_CMD_DATAIN | MFI_CMD_DATAOUT)) {
> cm->cm_data = data = malloc(cm->cm_len, M_MFIBUF,
> M_WAITOK | M_ZERO);
> if (cm->cm_data == NULL) {
> device_printf(sc->mfi_dev, "Malloc failed\n");
> goto out;
> }
> } else {
> cm->cm_data = 0;
2112,2119c2125,2135
< for (i = 0; i < ioc->mfi_sge_count; i++) {
< error = copyin(ioc->mfi_sgl[i].iov_base,
< temp,
< ioc->mfi_sgl[i].iov_len);
< if (error != 0) {
< device_printf(sc->mfi_dev,
< "Copy in failed\n");
< goto out;
---
> if (cm->cm_flags & MFI_CMD_DATAOUT) {
> for (i = 0; i < ioc->mfi_sge_count; i++) {
> error = copyin(ioc->mfi_sgl[i].iov_base,
> temp,
> ioc->mfi_sgl[i].iov_len);
> if (error != 0) {
> device_printf(sc->mfi_dev,
> "Copy in failed\n");
> goto out;
> }
> temp = &temp[ioc->mfi_sgl[i].iov_len];
2121d2136
< temp = &temp[ioc->mfi_sgl[i].iov_len];
2145,2152c2160,2170
< for (i = 0; i < ioc->mfi_sge_count; i++) {
< error = copyout(temp,
< ioc->mfi_sgl[i].iov_base,
< ioc->mfi_sgl[i].iov_len);
< if (error != 0) {
< device_printf(sc->mfi_dev,
< "Copy out failed\n");
< goto out;
---
> if (cm->cm_flags & MFI_CMD_DATAIN) {
> for (i = 0; i < ioc->mfi_sge_count; i++) {
> error = copyout(temp,
> ioc->mfi_sgl[i].iov_base,
> ioc->mfi_sgl[i].iov_len);
> if (error != 0) {
> device_printf(sc->mfi_dev,
> "Copy out failed\n");
> goto out;
> }
> temp = &temp[ioc->mfi_sgl[i].iov_len];
2154d2171
< temp = &temp[ioc->mfi_sgl[i].iov_len];
2281,2285c2298,2307
< l_ioc.lioc_sgl_off); /* Linux can do 2 frames ? */
< cm->cm_total_frame_size = l_ioc.lioc_sgl_off;
< cm->cm_sg =
< (union mfi_sgl *)&cm->cm_frame->bytes[l_ioc.lioc_sgl_off];
< cm->cm_flags = MFI_CMD_DATAIN | MFI_CMD_DATAOUT;
---
> 2 * MFI_DCMD_FRAME_SIZE); /* this isn't quite right */
> cm->cm_total_frame_size = (sizeof(union mfi_sgl) * l_ioc.lioc_sge_count) + l_ioc.lioc_sgl_off;
> if (l_ioc.lioc_sge_count)
> cm->cm_sg =
> (union mfi_sgl *)&cm->cm_frame->bytes[l_ioc.lioc_sgl_off];
> cm->cm_flags = 0;
> if (cm->cm_frame->header.flags & MFI_FRAME_DATAIN)
> cm->cm_flags |= MFI_CMD_DATAIN;
> if (cm->cm_frame->header.flags & MFI_FRAME_DATAOUT)
> cm->cm_flags |= MFI_CMD_DATAOUT;
2287,2288c2309,2318
< cm->cm_data = data = malloc(cm->cm_len, M_MFIBUF,
< M_WAITOK | M_ZERO);
---
> if (cm->cm_flags & (MFI_CMD_DATAIN | MFI_CMD_DATAOUT)) {
> cm->cm_data = data = malloc(cm->cm_len, M_MFIBUF,
> M_WAITOK | M_ZERO);
> if (cm->cm_data == NULL) {
> device_printf(sc->mfi_dev, "Malloc failed\n");
> goto out;
> }
> } else {
> cm->cm_data = 0;
> }
2294,2303c2324,2336
< for (i = 0; i < l_ioc.lioc_sge_count; i++) {
< temp_convert =
< (void *)(uintptr_t)l_ioc.lioc_sgl[i].iov_base;
< error = copyin(temp_convert,
< temp,
< l_ioc.lioc_sgl[i].iov_len);
< if (error != 0) {
< device_printf(sc->mfi_dev,
< "Copy in failed\n");
< goto out;
---
> if (cm->cm_flags & MFI_CMD_DATAOUT) {
> for (i = 0; i < l_ioc.lioc_sge_count; i++) {
> temp_convert =
> (void *)(uintptr_t)l_ioc.lioc_sgl[i].iov_base;
> error = copyin(temp_convert,
> temp,
> l_ioc.lioc_sgl[i].iov_len);
> if (error != 0) {
> device_printf(sc->mfi_dev,
> "Copy in failed\n");
> goto out;
> }
> temp = &temp[l_ioc.lioc_sgl[i].iov_len];
2305d2337
< temp = &temp[l_ioc.lioc_sgl[i].iov_len];
2329,2338c2361,2373
< for (i = 0; i < l_ioc.lioc_sge_count; i++) {
< temp_convert =
< (void *)(uintptr_t)l_ioc.lioc_sgl[i].iov_base;
< error = copyout(temp,
< temp_convert,
< l_ioc.lioc_sgl[i].iov_len);
< if (error != 0) {
< device_printf(sc->mfi_dev,
< "Copy out failed\n");
< goto out;
---
> if (cm->cm_flags & MFI_CMD_DATAIN) {
> for (i = 0; i < l_ioc.lioc_sge_count; i++) {
> temp_convert =
> (void *)(uintptr_t)l_ioc.lioc_sgl[i].iov_base;
> error = copyout(temp,
> temp_convert,
> l_ioc.lioc_sgl[i].iov_len);
> if (error != 0) {
> device_printf(sc->mfi_dev,
> "Copy out failed\n");
> goto out;
> }
> temp = &temp[l_ioc.lioc_sgl[i].iov_len];
2340d2374
< temp = &temp[l_ioc.lioc_sgl[i].iov_len];