[cam_periph_mapmen:?]
Kenneth D. Merry
ken at freebsd.org
Thu Aug 4 23:30:17 GMT 2005
On Thu, Aug 04, 2005 at 18:18:39 -0400, Heck, Steve wrote:
> I am having problems Writing to a SCSI tape drive.
>
> First the Block Size is being set to 65536 Bytes by Mode Select which succeeds.
>
> printf ("Data compression enabled.\n");
>
> buf_data1c[0] = 0x00;
> buf_data1c[1] = 0x00;
> buf_data1c[2] = 0x10;
> buf_data1c[3] = 0x08;
> buf_data1c[4] = 0x7f;
> buf_data1c[5] = 0x00;
> buf_data1c[6] = 0x00;
> buf_data1c[7] = 0x00;
> buf_data1c[8] = 0x00;
> buf_data1c[9] = 0x01;
> buf_data1c[10] = 0x00;
> buf_data1c[11] = 0x00;
> buf_data1c[12] = 0x0f;
> buf_data1c[13] = 0x0e;
> buf_data1c[14] = 0xc0;
> buf_data1c[15] = 0x80;
> buf_data1c[16] = 0x00;
> buf_data1c[17] = 0x00;
> buf_data1c[18] = 0x00;
> buf_data1c[19] = 0x00;
> buf_data1c[20] = 0x00;
> buf_data1c[21] = 0x00;
> buf_data1c[22] = 0x00;
> buf_data1c[23] = 0x00;
> buf_data1c[24] = 0x00;
> buf_data1c[25] = 0x00;
> buf_data1c[26] = 0x00;
> buf_data1c[27] = 0x00;
>
> //unsigned char header[len];
> memset( header, 0, len );
> memset(&ccb,0,sizeof(ccb));
> ccb.ccb_h.path_id = cam->path_id;
> ccb.ccb_h.target_id = cam->target_id;
> ccb.ccb_h.target_lun = cam->target_lun;
> cam_fill_csio (&(ccb.csio), 1, NULL, CAM_DIR_OUT, MSG_SIMPLE_Q_TAG, buf_data1c, sizeof(buf_data1c), sizeof(ccb.csio.sense_data), 0, 30*1000);
> ccb.csio.cdb_len = 6;
> ccb.csio.cdb_io.cdb_bytes[0] = 0x15; // Mode Select
> ccb.csio.cdb_io.cdb_bytes[1] = 0x10;
> ccb.csio.cdb_io.cdb_bytes[4] = 0x1c;
> ccb.csio.cdb_io.cdb_bytes[5] = 0x00;
>
> //int ret;
> if ((ret = cam_send_ccb(cam, &ccb)) < 0)
> {
> printf("cam_send_ccb: failed\n");
> cam_close_device(cam);
> return -1;
> }
>
>
> The problem occurs when I try to Write one Fixed Block.
>
>
> unsigned char wbuf_data[65536]
>
> memset( header, 0, len );
> memset(&ccb,0,sizeof(ccb));
> ccb.ccb_h.path_id = cam->path_id;
> ccb.ccb_h.target_id = cam->target_id;
> ccb.ccb_h.target_lun = cam->target_lun;
> cam_fill_csio (&(ccb.csio), 1, NULL, CAM_DIR_OUT, MSG_SIMPLE_Q_TAG, wbuf_data, sizeof(wbuf_data), sizeof(ccb.csio.sense_data), 0, 900*1000);
> ccb.csio.cdb_len = 6;
> ccb.csio.cdb_io.cdb_bytes[0] = 0x0a; // Write
> ccb.csio.cdb_io.cdb_bytes[1] = 0x01;
> ccb.csio.cdb_io.cdb_bytes[4] = 0x01;
> ccb.csio.cdb_io.cdb_bytes[5] = 0x00;
>
> if ((ret = cam_send_ccb(cam, &ccb)) < 0)
> {
> printf("cam_send_ccb: failed\n");
> cam_close_device(cam);
> return -1;
> }
>
> I get this error:
>
> cam_periph_mapmem: attempt to map 68480 bytes, which is greater that DFLTPHYS(65536)
>
> cam_send_ccb: failed
>
> I do not see the Write cdb being sent when I make a SCSI trace.
>
> Any help would be appreciated.
Here's the comment/code in question:
/*
* The userland data pointer passed in may not be page
* aligned. vmapbuf() truncates the address to a page
* boundary, so if the address isn't page aligned, we'll
* need enough space for the given transfer length, plus
* whatever extra space is necessary to make it to the page
* boundary.
*/
if ((lengths[i] +
(((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)) > DFLTPHYS){
printf("cam_periph_mapmem: attempt to map %lu bytes, "
"which is greater than DFLTPHYS(%d)\n",
(long)(lengths[i] +
(((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)),
DFLTPHYS);
return(E2BIG);
}
If you make sure your data buffer is page aligned, you should be able to
send a 64K request down through the passthrough driver.
Ken
--
Kenneth Merry
ken at FreeBSD.org
More information about the freebsd-scsi
mailing list