[virtio_magma] Use magma_internal_map/unmap

Change-Id: I93c99d0bfe1d86a8784c5bd3f13756d58e652fe0
diff --git a/drivers/virtio/virtio_magma.c b/drivers/virtio/virtio_magma.c
index d7e28c6..9ca8635 100644
--- a/drivers/virtio/virtio_magma.c
+++ b/drivers/virtio/virtio_magma.c
@@ -543,8 +543,8 @@
 	struct virtmagma_instance *instance = priv->instance;
 	struct virtmagma_connection *connection = NULL;
 	struct virtmagma_connection_object *object = NULL;
-	struct virtio_magma_unmap_ctrl *request = NULL;
-	struct virtio_magma_unmap_resp *response = NULL;
+	struct virtio_magma_internal_unmap_ctrl *request = NULL;
+	struct virtio_magma_internal_unmap_resp *response = NULL;
 	int ret;
 
 	if (instance) {
@@ -569,10 +569,11 @@
 			.response_size = sizeof(*response)
 		};
 
-		request->hdr.type = VIRTIO_MAGMA_CMD_UNMAP;
+		request->hdr.type = VIRTIO_MAGMA_CMD_INTERNAL_UNMAP;
 		request->hdr.flags = 0;
 		request->connection = priv->connection_id;
 		request->buffer = priv->buffer_id;
+		request->address = priv->phys_addr;
 
 		ret = vq_out_send_sync(instance->vi, &command);
 		if (ret == 0) {
@@ -603,8 +604,8 @@
 	struct virtmagma_instance *instance = priv->instance;
 	struct virtmagma_connection *connection;
 	struct virtmagma_connection_object *object;
-	struct virtio_magma_map_ctrl *request;
-	struct virtio_magma_map_resp *response;
+	struct virtio_magma_internal_map_ctrl *request;
+	struct virtio_magma_internal_map_resp *response;
 	unsigned long vm_size = vma->vm_end - vma->vm_start;
 	size_t max_map_size;
 	int ret = 0;
@@ -631,10 +632,11 @@
 		return -ENOMEM;
 	}
 
-	request->hdr.type = VIRTIO_MAGMA_CMD_MAP;
+	request->hdr.type = VIRTIO_MAGMA_CMD_INTERNAL_MAP;
 	request->hdr.flags = 0;
 	request->connection = priv->connection_id;
 	request->buffer = priv->buffer_id;
+	request->length = object->buffer.size_allocated;
 
 	mutex_lock(&priv->mutex_lock);
 	if (!priv->phys_addr) {
@@ -652,7 +654,7 @@
 		}
 
 		if (ret == 0) {
-			priv->phys_addr = response->addr_out;
+			priv->phys_addr = response->address_out;
 		}
 	}
 	mutex_unlock(&priv->mutex_lock);
diff --git a/include/uapi/linux/virtio_magma.h b/include/uapi/linux/virtio_magma.h
index 6178400..2243eef 100644
--- a/include/uapi/linux/virtio_magma.h
+++ b/include/uapi/linux/virtio_magma.h
@@ -79,6 +79,8 @@
 	VIRTIO_MAGMA_CMD_BUFFER_RANGE_OP = 0x1041,
 	VIRTIO_MAGMA_CMD_BUFFER_GET_INFO = 0x1042,
 	VIRTIO_MAGMA_CMD_GET_BUFFER_HANDLE = 0x1043,
+	VIRTIO_MAGMA_CMD_INTERNAL_MAP = 0x1044,
+	VIRTIO_MAGMA_CMD_INTERNAL_UNMAP = 0x1045,
 	/* magma success responses
  */
 	VIRTIO_MAGMA_RESP_RELEASE_CONNECTION = 0x2004,
@@ -139,6 +141,8 @@
 	VIRTIO_MAGMA_RESP_BUFFER_RANGE_OP = 0x2041,
 	VIRTIO_MAGMA_RESP_BUFFER_GET_INFO = 0x2042,
 	VIRTIO_MAGMA_RESP_GET_BUFFER_HANDLE = 0x2043,
+	VIRTIO_MAGMA_RESP_INTERNAL_MAP = 0x2044,
+	VIRTIO_MAGMA_RESP_INTERNAL_UNMAP = 0x2045,
 	/* magma error responses
  */
 	VIRTIO_MAGMA_RESP_ERR_UNIMPLEMENTED = 0x3001,
@@ -267,6 +271,10 @@
 		case VIRTIO_MAGMA_RESP_BUFFER_GET_INFO: return "VIRTIO_MAGMA_RESP_BUFFER_GET_INFO";
 		case VIRTIO_MAGMA_CMD_GET_BUFFER_HANDLE: return "VIRTIO_MAGMA_CMD_GET_BUFFER_HANDLE";
 		case VIRTIO_MAGMA_RESP_GET_BUFFER_HANDLE: return "VIRTIO_MAGMA_RESP_GET_BUFFER_HANDLE";
+		case VIRTIO_MAGMA_CMD_INTERNAL_MAP: return "VIRTIO_MAGMA_CMD_INTERNAL_MAP";
+		case VIRTIO_MAGMA_RESP_INTERNAL_MAP: return "VIRTIO_MAGMA_RESP_INTERNAL_MAP";
+		case VIRTIO_MAGMA_CMD_INTERNAL_UNMAP: return "VIRTIO_MAGMA_CMD_INTERNAL_UNMAP";
+		case VIRTIO_MAGMA_RESP_INTERNAL_UNMAP: return "VIRTIO_MAGMA_RESP_INTERNAL_UNMAP";
 		case VIRTIO_MAGMA_RESP_ERR_UNIMPLEMENTED: return "VIRTIO_MAGMA_RESP_ERR_UNIMPLEMENTED";
 		case VIRTIO_MAGMA_RESP_ERR_INTERNAL: return "VIRTIO_MAGMA_RESP_ERR_INTERNAL";
 		case VIRTIO_MAGMA_RESP_ERR_HOST_DISCONNECTED: return "VIRTIO_MAGMA_RESP_ERR_HOST_DISCONNECTED";
@@ -337,6 +345,8 @@
 		case VIRTIO_MAGMA_CMD_BUFFER_RANGE_OP: return VIRTIO_MAGMA_RESP_BUFFER_RANGE_OP;
 		case VIRTIO_MAGMA_CMD_BUFFER_GET_INFO: return VIRTIO_MAGMA_RESP_BUFFER_GET_INFO;
 		case VIRTIO_MAGMA_CMD_GET_BUFFER_HANDLE: return VIRTIO_MAGMA_RESP_GET_BUFFER_HANDLE;
+		case VIRTIO_MAGMA_CMD_INTERNAL_MAP: return VIRTIO_MAGMA_RESP_INTERNAL_MAP;
+		case VIRTIO_MAGMA_CMD_INTERNAL_UNMAP: return VIRTIO_MAGMA_RESP_INTERNAL_UNMAP;
 		default: return VIRTIO_MAGMA_RESP_ERR_INVALID_COMMAND;
 	}
 }
@@ -1015,5 +1025,30 @@
 	__le64 result_return;
 } __attribute((packed));
 
+struct virtio_magma_internal_map_ctrl {
+	struct virtio_magma_ctrl_hdr hdr;
+	__le64 connection;
+	__le64 buffer;
+	__le64 length;
+} __attribute((packed));
+
+struct virtio_magma_internal_map_resp {
+	struct virtio_magma_ctrl_hdr hdr;
+	__le64 address_out;
+	__le64 result_return;
+} __attribute((packed));
+
+struct virtio_magma_internal_unmap_ctrl {
+	struct virtio_magma_ctrl_hdr hdr;
+	__le64 connection;
+	__le64 buffer;
+	__le64 address;
+} __attribute((packed));
+
+struct virtio_magma_internal_unmap_resp {
+	struct virtio_magma_ctrl_hdr hdr;
+	__le64 result_return;
+} __attribute((packed));
+
 #endif /* _LINUX_VIRTIO_MAGMA_H
  */