/**
  * iscsi_sw_tcp_xmit_segment - transmit segment
- * @tcp_sw_conn: the iSCSI TCP connection
+ * @tcp_conn: the iSCSI TCP connection
  * @segment: the buffer to transmnit
  *
  * This function transmits as much of the buffer as
  * hash as it goes. When the entire segment has been transmitted,
  * it will retrieve the hash value and send it as well.
  */
-static int iscsi_sw_tcp_xmit_segment(struct iscsi_sw_tcp_conn *tcp_sw_conn,
+static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
                                     struct iscsi_segment *segment)
 {
+       struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
        struct socket *sk = tcp_sw_conn->sock;
        unsigned int copied = 0;
        int r = 0;
 
-       while (!iscsi_tcp_segment_done(segment, 0, r)) {
+       while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) {
                struct scatterlist *sg;
                unsigned int offset, copy;
                int flags = 0;
        int rc = 0;
 
        while (1) {
-               rc = iscsi_sw_tcp_xmit_segment(tcp_sw_conn, segment);
+               rc = iscsi_sw_tcp_xmit_segment(tcp_conn, segment);
                if (rc < 0) {
                        rc = ISCSI_ERR_XMIT_FAILED;
                        goto error;
 
 
 /**
  * iscsi_tcp_segment_done - check whether the segment is complete
+ * @tcp_conn: iscsi tcp connection
  * @segment: iscsi segment to check
  * @recv: set to one of this is called from the recv path
  * @copied: number of bytes copied
  *
  * This function must be re-entrant.
  */
-int iscsi_tcp_segment_done(struct iscsi_segment *segment, int recv,
+int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
+                          struct iscsi_segment *segment, int recv,
                           unsigned copied)
 {
        static unsigned char padbuf[ISCSI_PAD_LEN];
        }
 
        /* Do we need to handle padding? */
-       pad = iscsi_padding(segment->total_copied);
-       if (pad != 0) {
-               debug_tcp("consume %d pad bytes\n", pad);
-               segment->total_size += pad;
-               segment->size = pad;
-               segment->data = padbuf;
-               return 0;
+       if (!(tcp_conn->iscsi_conn->session->tt->caps & CAP_PADDING_OFFLOAD)) {
+               pad = iscsi_padding(segment->total_copied);
+               if (pad != 0) {
+                       debug_tcp("consume %d pad bytes\n", pad);
+                       segment->total_size += pad;
+                       segment->size = pad;
+                       segment->data = padbuf;
+                       return 0;
+               }
        }
 
        /*
 {
        unsigned int copy = 0, copied = 0;
 
-       while (!iscsi_tcp_segment_done(segment, 1, copy)) {
+       while (!iscsi_tcp_segment_done(tcp_conn, segment, 1, copy)) {
                if (copied == len) {
                        debug_tcp("iscsi_tcp_segment_recv copied %d bytes\n",
                                  len);
        /* We're done processing the header. See if we're doing
         * header digests; if so, set up the recv_digest buffer
         * and go back for more. */
-       if (conn->hdrdgst_en) {
+       if (conn->hdrdgst_en &&
+           !(conn->session->tt->caps & CAP_DIGEST_OFFLOAD)) {
                if (segment->digest_len == 0) {
                        /*
                         * Even if we offload the digest processing we
                        return 0;
                }
 
-               if (!(conn->session->tt->caps & CAP_DIGEST_OFFLOAD)) {
-                       iscsi_tcp_dgst_header(tcp_conn->rx_hash, hdr,
-                               segment->total_copied - ISCSI_DIGEST_SIZE,
-                               segment->digest);
+               iscsi_tcp_dgst_header(tcp_conn->rx_hash, hdr,
+                                     segment->total_copied - ISCSI_DIGEST_SIZE,
+                                     segment->digest);
 
-                       if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
-                               return ISCSI_ERR_HDR_DGST;
-               }
+               if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
+                       return ISCSI_ERR_HDR_DGST;
        }
 
        tcp_conn->in.hdr = hdr;