  We compute the luminosity function (LF) and the formation rate of long gamma
ray bursts (GRBs) in three different scenarios: i) GRBs follow the cosmic star
formation and their LF is constant in time; ii) GRBs follow the cosmic star
formation but the LF varies with redshift; iii) GRBs form preferentially in
low-metallicity environments. We then test model predictions against the Swift
3-year data, showing that scenario i) is robustly ruled out. Moreover, we show
that the number of bright GRBs detected by Swift suggests that GRBs should have
experienced some sort of luminosity evolution with redshift, being more
luminous in the past. Finally we propose to use the observations of the
afterglow spectrum of GRBs at z>5.5 to constrain the reionization history and
we applied our method to the case of GRB 050904.
