Lines Matching defs:gw

673 static void gcm_walk_start(struct gcm_sg_walk *gw, struct scatterlist *sg,
676 memset(gw, 0, sizeof(*gw));
677 gw->walk_bytes_remain = len;
678 scatterwalk_start(&gw->walk, sg);
681 static inline unsigned int _gcm_sg_clamp_and_map(struct gcm_sg_walk *gw)
685 gw->walk_bytes = scatterwalk_clamp(&gw->walk, gw->walk_bytes_remain);
686 while (!gw->walk_bytes) {
687 nextsg = sg_next(gw->walk.sg);
690 scatterwalk_start(&gw->walk, nextsg);
691 gw->walk_bytes = scatterwalk_clamp(&gw->walk,
692 gw->walk_bytes_remain);
694 gw->walk_ptr = scatterwalk_map(&gw->walk);
695 return gw->walk_bytes;
698 static inline void _gcm_sg_unmap_and_advance(struct gcm_sg_walk *gw,
701 gw->walk_bytes_remain -= nbytes;
702 scatterwalk_unmap(gw->walk_ptr);
703 scatterwalk_advance(&gw->walk, nbytes);
704 scatterwalk_done(&gw->walk, 0, gw->walk_bytes_remain);
705 gw->walk_ptr = NULL;
708 static int gcm_in_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
712 if (gw->buf_bytes && gw->buf_bytes >= minbytesneeded) {
713 gw->ptr = gw->buf;
714 gw->nbytes = gw->buf_bytes;
718 if (gw->walk_bytes_remain == 0) {
719 gw->ptr = NULL;
720 gw->nbytes = 0;
724 if (!_gcm_sg_clamp_and_map(gw)) {
725 gw->ptr = NULL;
726 gw->nbytes = 0;
730 if (!gw->buf_bytes && gw->walk_bytes >= minbytesneeded) {
731 gw->ptr = gw->walk_ptr;
732 gw->nbytes = gw->walk_bytes;
737 n = min(gw->walk_bytes, AES_BLOCK_SIZE - gw->buf_bytes);
738 memcpy(gw->buf + gw->buf_bytes, gw->walk_ptr, n);
739 gw->buf_bytes += n;
740 _gcm_sg_unmap_and_advance(gw, n);
741 if (gw->buf_bytes >= minbytesneeded) {
742 gw->ptr = gw->buf;
743 gw->nbytes = gw->buf_bytes;
746 if (!_gcm_sg_clamp_and_map(gw)) {
747 gw->ptr = NULL;
748 gw->nbytes = 0;
754 return gw->nbytes;
757 static int gcm_out_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
759 if (gw->walk_bytes_remain == 0) {
760 gw->ptr = NULL;
761 gw->nbytes = 0;
765 if (!_gcm_sg_clamp_and_map(gw)) {
766 gw->ptr = NULL;
767 gw->nbytes = 0;
771 if (gw->walk_bytes >= minbytesneeded) {
772 gw->ptr = gw->walk_ptr;
773 gw->nbytes = gw->walk_bytes;
777 scatterwalk_unmap(gw->walk_ptr);
778 gw->walk_ptr = NULL;
780 gw->ptr = gw->buf;
781 gw->nbytes = sizeof(gw->buf);
784 return gw->nbytes;
787 static int gcm_in_walk_done(struct gcm_sg_walk *gw, unsigned int bytesdone)
789 if (gw->ptr == NULL)
792 if (gw->ptr == gw->buf) {
793 int n = gw->buf_bytes - bytesdone;
795 memmove(gw->buf, gw->buf + bytesdone, n);
796 gw->buf_bytes = n;
798 gw->buf_bytes = 0;
800 _gcm_sg_unmap_and_advance(gw, bytesdone);
805 static int gcm_out_walk_done(struct gcm_sg_walk *gw, unsigned int bytesdone)
809 if (gw->ptr == NULL)
812 if (gw->ptr == gw->buf) {
814 if (!_gcm_sg_clamp_and_map(gw))
816 n = min(gw->walk_bytes, bytesdone - i);
817 memcpy(gw->walk_ptr, gw->buf + i, n);
818 _gcm_sg_unmap_and_advance(gw, n);
821 _gcm_sg_unmap_and_advance(gw, bytesdone);